Refactored stuff a bit.