Add debugging and testing code