New reworked and commented version.