Fix some errors and clean debug messages.