refactor Entity's store_attributes method

This PR splits store_attributes into smaller methods and slightly restructures the logic.  A few fields get renamed.

This was partly an exercise to help me understand the code better.