Refactored the way in which mongoose schema types were detected, to something more reliable.