Added Save functionality and formatted code.