save files to original name and some bug fixes
refactored file saving/fixed bugs