Fix flag proccessing