Refactored the lot. Made it faster and more specifiic for different types of aliases.