Moved chip code into a class