Various fixes (mostly PHP notices) + better handling of external URLs

Should fix #15