Added flush function and a structure for holding frames