added autosave, and modified some parameters, hoefully the code will be faster