Board flipping bug fix, refactoring
-The logic that handled flipping the board was not adjusting some higlighting logic, so now board flipping works as expected.
-Refactored some sections for readibility.