Updated the code to be more in line with the recommended style
guidlines.
Also added an additional debugging function.