Lots of fix and tweaks