Modify some throw and remove clear on initialize

Modify some throw and remove clear on initialize
Format some code

Format some code