Shared code used for (SPOT)light, (SPOT)id and other analyses