Attempt bugfixing on segfault (heap corruption)