Move dynamic method generation to class instead of object level