Building flags optimization