Reimplement changes from 2013-11-06 which were lost in last merge