Update refactor to use inline memory allocation