Lots and lots of fixes

See the commit messages & diffs for the exact listing of what was changed and why. :)