Lots of fixes which presumably make us handle data more safely