Merge bug fix and glue improved from last pull req

As discussed in the rejected pull-request: glue is now a module function and does not require a deep copy. It still verifies the same unit tests.