First stage of weave optimization

All the components are mappend into a flat array and the paths as converted
from component indices to pairs of start/stop positions in the flat array.
Everything else is also flattened to 1D arrays for easy access in the C code,
so there is some extra bookkeeping for offsets/sizes.

Next stage is to pack all paths as well and then iterating over them from C.