Implemented new gradient policy loop.