Refactored buildFacetArray and cleaned up the result arrays a bit.