Fixed some memory management issues and vulnerbility where cubescript could be inserted into commands.