implement state machine design pattern

Move stuff into BOM namespace
Merge pull request #1 from PapaMarky/state-machine

implement state machine design pattern