Re-factored where statements into their own methods to make unit testing easier;
Fixed an issue with a missing ! on getting the base template IDs