Manually add changes from @rterbush #2 pull request