Major refactoring. Dropped some tests :(