Changed definition to polymorphic.
Fixed bugs.