Little bug fixes and cleanup.