Split various functionality into separate functions.