use bash 4.3ism to build arrays where possible
automatically clean up after ourselves if we can

Resolves GH#4.