Refactoring + Bugfixing to run setup