modify file and fix few bugs.