Added time management and corrected UI handling