simplified structure, added diagnostic printouts to http_handler