Merging some code from my other repo.

Added some comments and fixed some postinstall scripts to set correct
permissions.