translated and refactored up to line 1045
Minor