General bug fixes and clean up.