Added number of iterations and fixed bugs with maxiter