Lots of fixes and additions