merge to python2.7

fix small bugs make it run.
still not thread safe