Suggested refactoring:

```erlang
Opts0 = [{rw, RW}, {r, R}, {w, W}, {pr, PR}, {pw, PW}, {dw, DW}, {timeout, Timeout}],
Options = [ {Opt, Val} || {Opt, Val} <- Opts0, Val /= undefined, Val /= default ]
```

That pattern might also be useful in these other places where you conditionally include the timeout option, e.g.

```erlang
Opts0 ++ [ {timeout, Timeout} || Timeout /= undefined ]
```