Fixed the code not properly detecting flags and associated bases.