Refactor EntityStore

Change-Id: If8cfe64020d056fda028c9dc8f275ee6eb4a65c7