Cleaned up the chip interaction code