Fix and improve getting source