Add extensive documentation to the code