patched a bug in core-writing