implemented some specs
Lots of refactoring