some bugfixes, still not bugfree..