Improved code to detect theories.

In case theories were caught instead of discussion code now detects and better tries to find discussion.

Code also runs until there are no more links to be posted.