bug fixes and more refactoring