lots of bugfixes. should work now