Replace uses of is_none, is_some and unwrap with pattern matching