Fixed infinite scroll issues and added error handling