Bug fixes, cleanup.