Switched to a c-array based implementation (currently has some memory trouble)