Bug fixes and updates!

See commit messages. Some good stuff here.