Code refactoring: reducing complexity of Production class

Moved part of Production class code to new class CodeSequence.