Updating the gateway script to properly anchor resources and profiles.