Fix saving of sources by adding more advanced promises implementation