Added debugging. Changed to interrupt based polling.