renderer2: cleanup and made program selector a lot faster, refs #321