WIP BROKEN
First working version passing tests
Merge missing commit (discarded changes from it)