Fix a bug reported by Jim Eng and another one reported by Eric Echeverri