The IPv6 routing protocol for low-power and lossy networks (RPL) has been recently standardized by the Internet Engineering Task Force (IETF) routing protocol for low-power and lossy networks (ROLL) working group to support IPv6 routing for resource-constrained devices in industrial, home, and urban environments. However, several studies have shown that RPL may experience (very) low delivery rates, particularly in large-scale deployments. In this paper, we provide an in-depth analysis of the protocol attributes and design choices that generate such unreliability issues. Then, we describe and evaluate a new implementation of the RPL standard for the Contiki operating system (OS) to improve data delivery reliability. The salient feature of our RPL implementation is to adopt a flexible cross-layering design that provides simple routing optimizations, enhanced link estimation capabilities, and efficient management of neighbor tables. In order to verify the effectiveness of our RPL implementation, we use an advanced metering infrastructure (AMI) as a case study. Results obtained using Cooja emulator in two sets of experiments, differentiated by the presence or lack of duty cycling, indicate that our RPL implementation outperforms the one provided in Contiki in terms of average packet delivery rates by up to 200% in networks with 100 nodes.