opt code tree and enhance features