Revert "Switched to using a simple malloc'd buffer"

This reverts commit 65d4fc1b5753da47218265ae0b5a1db831a9f25d.
Elenril rethought, given context
Now with proper memory management