Merge from Imtovs personal fork.