- replaced all mallocs/frees with pkg_malloc/pkg_free