Put EntityId parsing code into its own class

Got rid of lots of evil stuff :)

Change-Id: Icb9f02869a818756972b64f7bff392ce976fa2a6
Merge "Put EntityId parsing code into its own class"