major memory and array-handling redesign, closes #20