Final version (more comments in code)