Added support for building URLs with optional parameters

Fixes some of the issues mentioned in #290