Refactoring certain parts of the code, more to come