Lots of fixes and house keeping