more changes from original hg repo