Lots of fixes etc