Added documentation for many functions