Further improvcements to web serving code
Removed dead code and fixed stack overlow