proxy code copy from code.google.com/p/icefox