Fixed a collection of minor bugs.