Added documentation
Some more bug fixes