Fixes #353, many thanks to @justinrosenthal for reporting