added appropriate comments
created header file for grid, moved appropriate
declarations there
replace error message with proper asserts