Added bugfixes

So many bugs... ;(