Added synchronized to generateNewID() and removeEntity()