Commented version. And a partially commented. READ THE COMMENTS!