Fac less agressive for walls, Main reorganized

I changed the order of some isntructions in the main and corrected a bug
for the calculation of the maximum x position.