Refactoring, few bugfixes, specs.