Another attempt to fix a buffer overflow error on ubuntu (optimized mode only, making it hard to debug...)