The above code is composed of several subroutines, each one being well described by the text at the top of each subroutine.