Added more tracing and documentation