Cleaned code, commented a bit