minor cleaning and bug fixes