Cleaned code and more comments