refactoring code, and fixing critical bugs