Difference equations, stability theory and applications