added saveConfig function + cleanup