Further movement of code into separate files

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>