Replaced switch with if/else, that surprisingly removed compilers confusion that prevented loop unrollin