ported frontend request processing code from ruby to C