bug fixes. see redmine issues #78 and #82