Improved stability by fixing the crashes due to access to empty container front().