Fix for a bug reported by @wmanfield and @killswtch.