Fix top-level packages detection.
Try to fix sql syntax for candidates search.