Fix possible NPE with database query from program table.
Fixed possible crash with activated program table.