Fix minor errors

Fix "Array to string conversion" and "Illegal string offset" errors. Output is unchanged.