Add some comments better explaining what the various functions do

@ioerror hope you like the comments ;)