Modifying code to allow for better stability