Use IORD function for Switches and Keys.  The buttons would stop working randomly before, possibly due to the processor caching.  This seems to fix the problem