Ongoing pure functional conversion...
Added bunch of tests.
More tests.
More tests and beautification.
More refactoring towards pure functional code. :)
More tests.
Finally working. :)