A lot of fixes and tweaks