Fixed bug in table wrapping script that would move the table to be last child of its parent.