Apply codereview.appspot.com/8544043 and 8567043 and adapt the offline article