Lots of tweaks and fixes.

You know how it goes.