Merge fixes in "optimized" branch