Implements add/remove entity features, caches some query results in session variables