Adds `if let` to replace several uses of `unwrap`.

Also moves `allow(dead_code)` up to the crate root.