Improved cookie handling
Added some logging lines
Fixed argument error