Perf improvements

I went on a little hunt into performance and found a few pieces of low hanging fruit. These brought down scanning time from 5.5 seconds to 2.2 seconds for a camera sized image on an iPhone 4.