remove some more code duplication, fix a string, and remove a potential bug