Fixed save function.