carving: implement preprocessing

fixes #88, fixes #163