Fix flag errors for building with optimization, generate define tags