Add smart constructor as suggested by @jaspervdj.