moves some things around and update references