This is code that incorporates Daniel's comments, and adds a test for optimized modbus mapping.