Fix issues around moving to external function