This will need to be used in surfaces as well, in the future. Prepare for that by moving this code into its own file and struct.