First steps at formatting code for use as a library