add latest code from mercurial repo