New version completely tested and corrected. Including FA gradient algorithm