part 3 of updates - sorted out main header, added state control
- added the ability to use custom error codes