Some code refactoring. Removed unused classes too.