Refactored a bunch of things