Better url handling, fixed bug