Merge tgeller's changes

Please comment on the pull request (not individual commits) if you want to revert / edit some of tgeller's suggested changes.