cleaning and bug fixes