Refactor of functions that don't belong to image, out of the class.