Bugfixes

Hopefully a working build - still WIP however!