moved helper functions for sort, grid etc. calculations to helper file. Z-buffer sorting now works.