Refactor init of transformer