Implemented state_id() for entities. Closes #80.