Memory optimizations and minor cleanup
Merge pull request #6 from ebowman/memory-ops

Memory optimizations and minor cleanup