A few small optimizations
Merge pull request #38 from jcrudy/speedup

A few small optimizations