Complete rework of core wrapper -> no longer uses malloc