add flag to control use of template haskell
add missing cases in unpickle functions
Merge branch 'master' into upstream