Added update frquency as an input argument. Added comments and a safety check for replay memory being zero (learning cannot happen).