Fixes a major bug which resulted in data loss