several fixes and cosmetic fixes