add --trace-level option and fix debug outputs