Fixed bugs with saving data