Made the grid sliding code less cruptic, along with various other changes