Added code to be smarter about overwriting files

Fixes #11