Edited a few things to make centroiding more sensible, but haven't properly tested