Refactor library
Add documentation; clarify tracing functions
More documentation