Bug fixes and cleanups.