Added checks if files exists, fixed bug when overwriting data in the tpd file.