Fixes redmine #772 and #773