Refactored selena agent (running as a daemon now, with improved performance and stability)