fix some style, fix some var names, add some comments