Enhanced scope tracking and lookup functionality.