Small bug fixes in new code