repair some broken parts of the code