Fixed to allow pieces to be placed on the edge of the board. Tidied up codebase.