Complete refactoring

close #26