Removed overly dramatic findClosestSquare function and replaced with much simpler version. I must have been tired when I wrote that..