Adding some optimizations to the lambda serialization.