Fixed hard_auto_grid() function. It should be working now. However, it is very very time consuming.