First heavy round of bugfixes, still not working though