merged with li's clean branch.