Fixed file saving bugs in all routines