Brought in changes from dshurt version.