Refactored several things.