Copied changes from master.