Bunch of bugfixes

I merged all relevant changes >:(

+ everything works now.