Merge with Eugene's code