backout PR #298

I was able to track down the source of installation/upgrade errors in the master branch and identify the cause as PR #298.

This is a very large pull request which combines the refactor of the ancient and crusty Lockfile code with a number of other refactors. After spending two days attempting to restore functionality to the master branch I feel it is best to revert these changes and go for an attempt number two. The second attempt should contain nothing more than the refactor for the Lockfile.