flag handling and struct additions