Fixes in areas pointed out by Mark