Mostly working, some interesting bugs left.