Improved performance just a hair using Python constructs.