Cleaned code and documented