Cleaned the code a lot