fix bugs in debug codes.