Correctly copy derived classes

When a derived class is requested to copy it should
get a new instance of the derived class and not always
a instance of the state machine base class, so we should
make that happen correctly.