This change is probably too simplistic, but most things appear to work, so I don't care about that now. Fixes #1232.