fixed malformed url problem and some cosmetic improvements