fix some bugs, tested on production env