Bugfixes, but now seems to work!!