fix some core bugs