Refactor creation of supervisor