refactor Entity's store_attributes method

split into smaller methods and slightly restructure