Some fixes and cleanup.