Fixed segfault caused by overflowing memory accesses
Merge pull request #170 from rdnelson/mem_segfault_fix

Fixed segfault caused by overflowing memory accesses