changes to ray, added counters