Adding some comments and type signatures to aid my understanding a little