Improve attribute element mapping API and refactor