some refactoring and adding basic admin functionality