Finished functionality. Tidied up comments.

Still didn’t get it using proper OO. Maybe later.