Add some proper-tail-calls declare
Fix compile error in logview
Add termination to event loops