Apply changes from PR#8 that actually made sense.