num_retrieved as parameter, bugfixes