add flag to control use of template haskell
add missing cases in unpickle functions