Closes #548

Manual cherry-pick of 42df79364108ba7c78cbc8db1b07560963caf284 from
@sfrisby