Added support for grid data
initial move for code originally in svn