Started some refactoring