Approximate order of magnitude performance improvement, fixed idiomatic errors.

Very minor actual algorithm changes. I think it'd be cool to do map_pixel in assembly. I tried to isolate "stylistic" changes to their own commits so you can easily discard them if you like.