Minor bug fixes/code cleanup.