Removed unused stuff, cleaned the code, addedd missing comments