Better HTTP redirect handling; bug fixes