refactoring: splitup data.js into several modules, still not clean-enough...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
more refactoring, rearanged sort-related functions and re-written image/gid distance related code...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>