Fixed object deep copy in TableUtils

A bug with setting metatables in the TableUtils.deepCopy function caused
objects to lose their metatable when copied. This has been fixed by
moving the setmetatable call to the beginning of the function so it is
called when recursion starts.