Memory and code optimizations
Merge pull request #3 from dbonadiman/master

Memory and code optimizations