Improved data deserialization algorithm

Still need to do bounds checking when deserializing.
Function is now a template class to support lambdas as actions

For the compiler to automatically determine the type of the Function
object a template factory function is used (compiler can automatically
determine the type of a function but not of a class).
Updated examples