Added documentation. Fixed issues