fix some bugs, ready for customer review