Ready to submit

I did some simple tests and fixed a couple of bugs, now I think it's
pretty much done for now.