fix some bugs in the core.