Re-added some incorrectly removed code