Added variable board size

fixed a lot of stuff
code cleanup and comments