Adding dir creation and other code cleanups related to #61