Refactoring. Adds devirtualization optimization