Add support for preprocessing head and tail labels

Closes issue #12