Moved some recurring functionality into the helpers.