Merge "Do not do a layout and write while a cancellation is in progress." into klp-dev