added cookie support, updated readme, some minor refactoring.