Updated to properly encode arrays.