Fix for #112 - be aware of types when building insert query.
Fix update while we are at it.