the wall had been built some time after the troll invasion ; mostly to keep the trolls and other creatures of the swamp from wandering into town and creating a ruckus , but also in part to stem the settling of the swamp .