moved some duplicate code into parts.c from the 3 different backend impls