d332c00e2f
Motivation: Currently we do more memory copies then needed. Modification: - Directly use heap buffers to reduce memory copy - Correctly release buffers to fix buffer leak Result: Less memory copies and no leaks