Merge "Refactoring in preparation for OBMC optimizations." into nextgenv2