Code clean-up + more strict redirects handling