Merging in TfT_02's changes.

This should merge in all of the changes made by @TfT_02 in his current pull request.