Added some more comments and made methods protected so you can change the behaviour in child classes.