Added overwrite option, some other smaller changes