Improved URL handling and other fixes

ok :(