forward port 307324aaa4d434157c3726ac93efb184f5d60d74 to big refactor
forward port c393859a6c02d9d6c96d1df9831a73ec303c1edd to big_refactor