implemented save function for TM and LM. added additional cleaning for filemanagement.