changed redirection and added some headers support