Trunk 4015

My solution to TRUNK-4015 after discussing with dkayiwa on IRC.