Added the logic to do the A flag and hopefully make a pretty easy swing over to the B flag as well.  Here goes.