Support outer id and fix some bugs.