Handle dubious input in Gremlin wrappers better

There are a couple of utility routines on Gremlin that would throw errors when passed primitives (when working with cap), or nulls (when handling an empty pipeline). These commits catch the errors.