Protsenko bugfixes

Bug fixes #307  and #296