Refactoring a few things