Fixed several bugs, and added black square logic.