split out some clearly defined bits to modules