bug fixes and cosmetic changes