Lots of fixes for lots of different things.

I no longer use the project, but I do accept MR's, so please contribute if you can.