Cleaning up the code a bit

Pretty sure the code is the same as before, but removed a lot of cruft.