Fixing exception handling in Prolog management. Increased timeout for query parsing by Prolog. Fixes #1672.