Fix #39

See http://stackoverflow.com/a/1408476