fix some severe bugs