Started breaking out functionality into separate functions.