Cleaned code and updated comments