Tidy up mallocing in the loader