Fixed bugs in def creation.