Revised implementation of the driver and the main module.