Add monitoring and hash gradient var
Minor comments and tests