Fixed nullpointers and changed local-file scanning a bit.