create replacement entity and many little fixes