Optimized buffer model, memory debugged with Valgrind