Updated documentation. Cleaned code