Refactored a few things