Lots of minor changes to make things validate