Code reference from my Qbox blog posts.