Changed some mising between std and cv structures. Now mostly cv structures are used throughout the algorithm.