There exist several open source 6LoWPAN stacks for researchers to experiment with. However, they often lack sufficient and in-depth description of the internal operation, which makes extending the stacks difficult for many of us. This paper is an extended version of our previous work documenting the internal logic of an implemented and working 6LoWPAN stack, Nanostack (v1.1). We present first the main architecture of the stack and subsequently describe the path followed by a packet transiting the different layers. Then we provide details of each one of the layers in the stack, with exception of the ICMP layer. The main logic in the MAC layer is comprehensively explained, and an undocumented layer used in nodes working as Gateway, the NRP layer, is presented. In addition we provide a conceptual view of the layering of the stack relative to the hardware platform and enumerate the typical tasks running in a sensor node.