added cookies + refactored some code + started documenting for the 1st pull request