Fixed some flaws in StatefulTrait.