Correctly handle defaults and optional params