Added Insights support, moved main loop, removed obsolete code