Applied Andrew's patch