re-arranged and cleaned the debugging stuff