Addresses #6; tmp files are now removed on successful entry into the db