Lots of fixes