Added flags and fixed data saving
Removed debug print