Implement sbc
Refactor flag setting