public function runCommand( $command, $args = array(), $timeout = 86400 ) {

		// Convert a string args to an array
		if(!is_array($args)) $args = array($args);

		// Set a timeout so it's always set to either the default or the passed in parameter
		$timeout = ( isset( $timeout ) ? intval( $timeout ) : $this->connection->timeout );

                // Trim and then cast the command to a string, just to make sure
                $toWrite = strval( trim( $command ));

		// If the args is an array, then first escape double quotes in every element, then implode to strings delimted by enclosing quotes
		if( is_array( $args ) && ( count( $args ) > 0 )) {

			// This was causing an array to string conversion during the status command
			//$toWrite .= ' "' . implode('" "', str_replace( '"', '\"', $args )) . '"';

			// We need to escape any args that contain double quotes
			$args = array_map(function($element) {

				if(is_array($element)) {

					return array(str_replace('"', '\"', current($element)));

				} else {

					return str_replace('"', '\"', $element);
				}

			}, array_filter($args, function($element) {

				// Filter out any array elements that are also arrays
				return !is_array($element);
			}));

			// Make sure the args array is not now an empty array (in case it was filtered above)
			if (count($args) > 0) {

				$toWrite .= ' "' . implode('" "', $args) . '"';
			}
		}

		//Log::info( 'LxMPD runCommand toWrite', array($toWrite));

                // Write command to MPD socket
                $this->write( $toWrite );

		// Set the timeout in seconds
		$this->connection->setStreamTimeout( $timeout );

                // Read the response from the MPD socket
                $response = $this->read();

		// Set the timeout in seconds
		$this->connection->setStreamTimeout( $timeout );

		//Log::info( 'LxMPD runCommand response', array($response));
		//Log::info( 'LxMPD runCommand command', array($command));
		//Log::info( 'LxMPD runCommand args', array($args));

                // Return the parsed response array
                return $this->parse( $response, $command, $args );
        }