Code

cleanup: use internal memory allocation wrapper functions everywhere