Refactoring to enable voxel level parallelism using openmp

Tested on Linux and OSX x86_64. To enable compile with -fopenmp.