Finish refactoring

Soloved #7