Trying to clean up some code, I wrote this a loooonnggg time ago.

Just shuffling code around, deleting unneccessary lines, refactoring
repeated code.