Fixes MESOS-37, reviwed at https://reviews.apache.org/r/2663/diff/ Thanks to Ed Kohlwey and Charles Reiss for contributing this patch!