- Tidied the code via astyle.
- Removed the STATEFUL definitions.
- more tidying.
- tidying.
- tidying.