Refactor scaffolding engine so it can be used from outside