Externalize engine function. Still ugly as balls.