add documentation and cleanup