Factor out optparse etc from executables #7

Closes #7