Few bugfixes

#closes 589