rebase, review comments and fix a compile error