Fixed client
Fixed 301 redirect error
Cleaned up code