bugfixes

fixed a few bugs after refactoring