Removed logging to stderr and fixed timeout handling
Invoke callback via invoke_callback func
Merge pull request #798 from mannol1/master

Fixed segfault, timeout handling and logging.