More bugfixes. Finally got it to work