[fix] #584 #578

succeeds #623
new pull request since changes happened between last one and commit; please review quickly, thanks!