refactor Entity's store_attributes method

split into smaller methods and slightly restructure
Merge pull request #2 from mattdrees/refactor-store-attributes

refactor Entity's store_attributes method