Improve comments and error tracing