modified core files to generalize tile grid

@kalbermattenm : generalised matrix settings. please give it a quick glance