Added a contingency in case of macro failure
Cleaned up and commented code. Added introduction.