Version 3.1

Comments have been added to parts of the code to make it easier to
understand