Refactor the configure script

Purpose

Simplify the configure script by moving the generic functionality of managing a configuration to a separate module.

Responsibilities of configure