Fix unsafe behavior uncovered in #36