More bugfixes. Seems to be working now