Lots of stuff.

Me bad! Lots of unrelated things in this commit. Sorry :-(