Fix loops to be OpenMP compatible and #ifdef openmp functions to be linux (and hopefully MSVC) compatible.