Fix issue #1.

In code review #1, we talked about encapsulating the state_machine structure instead of putting it in the header. This pull request fix this. For the second part of the bug (state enter and exit callbacks), I think we sould not implement it now and reopen a pull request if we need this functionality later.

@pierluca Can you review this and merge if it looks ok ?