Improved the code I wrote for PointClouds earlier.