Merging latest changes in the master branch.

Lots of changes happened since the original version.