Quick refactor to prepare for greater reuse and flexibility of the code base