Made saving more robust