Changes in getstate and regtable.

[Bugfix] Missing int conversion in getstate.
[Add] Now users can define a new number to be the maximum number of
iterations the program will do if thinks is stuck in a loop.