Improved error handling when saving flags
removed debug output
improved error handling when saving flags
improved error handling when saving flags, remvoed debug output