added grid for faster queries
added debug info