Refactored code to use polymorphism

This commit also removes hack with bytecode and block attributes