Added documentation and tests. Clean up