Added cookie support and fixed a lot of things