Review and changes from Jocelyn Fiat

This should be a cleaner solution than mine.