Bug fixes and clean ups