Initial working version

TODO: tests damnit!
Test file