Function destroy, been rewrite.

Function destroy converted to userdata and a array table.