Refactor and enhance the hardware simulator. This is not yet a working version.