support for virtual methods and some refactoring and fixes