This reverts commit de71def3. This is causing some very large changes, so I'm first going to break this patch down and re-commit in parts.