Fixed function that was making Q a matrix instead of vector.