Shuffled the code around a lot, readability