Refactor State

Two major improvements have been made to State:

1) The introduction of the class Bot enables a much cleaner code,
and greatly improves re-usability of some code blocks.

2) With the implementation of tests for State, some critical bugs
were found and have been resolved.