Program Logic moved to separated file (core.py)

Some functions had to be changed due to session handling between the
files.

There was also a teardown_request function added for better SQL session
handling.
Merge pull request #2 from deckn/master

pull nach eng keier du Sau ;)