Took David's changes and incorporate it into the branch