Code updgrade

More verbose, cleaner, correct some mistakes