Add ptree serialization, remove globals using lambdas.