Made most, hopefully all serialization functions be templatized.