Some Refactorings

Some refactoring changes (see commit messages). :)