Cleaned the code up a lot