Rewrite Debug class

+ Remove duplicated code
+ Use StringBuilder Instead of String concatenation