Bug fixes in core library