rest_proxy.php: numerous enhancements and fixes