Updated structure auto detection to work with multiple data sources.