pulled in changes from @stanzheng fork.