Refactor attribute detection and loading