Some bug fixed and pep8 format