Final bug fixes and code refactoring continues