Changed class Optional to struct to reduce heap allocations.