bug fixes and other improvements. styles refactoring