Reviewed, tweaked, and landed by Anders Carlsson.