Refactor some functions to use point objects instead of indexes