Updated code as a result of fix for  http://phabricator.cubex.io/T170