Thanks for the answers, guys.

This is actually for a research project at university. This code has been worked on by a few people over a few years and it's not documented at all. Comments are far and few in-between. There is no way I can justify a re-write, but I am taking the advice of going through each line and commenting as much as possible.

This is sort of a coding nightmare!