Fixed reading and writing to IO ports