fix bug open broken file and update all code style, add more comment