Simplify code and allow options to be set.