Bugfix + work on tests (WIP).