Fix bugs in core.