Merged loladiro's patches and fixed bug in URL forming