Minor bug fixes, cleanup.