Added loadpath code and fixed file saving