Refactoring

- Fixed minor bugs that was stopping sorting when the default_scope was set.
- Removing duplicate code
- Trying to make classed shorter by moving few methods into additional files