First version

Mostly working, but needs some work.