Prettied up the code. Fixed minor mistakes.

Code as most definitely not working. Need help to proceed, though. The
functions certainly have less input variables, but they are almost 100 %
certainly not correct. Should have a look at that fairly soon.