Compiled and debugged partially.
TODO: add proper logging in place of the State vector, which is somewhat unreliable in the threading scheme.  Instead, we'll use the AppLog, which is thread-safe.