merge part 2 of Cesar's patch