major improvements to optional argument handling