Refactoring and minor fixes

See commit comments for changes.

This should be applied before we head into refactoring Selectors into Filters as per Issue #40 due to the large amount of refactoring.