Smoking is known to be one of the main causes for premature deaths. A reliable smoking detection method can enable applications for an insight into a user's smoking behaviour and for use in smoking cessation programs. However, it is difficult to accurately detect smoking because it can be performed in various postures or in combination with other activities, it is less-repetitive, and it may be confused with other similar activities, such as drinking and eating. In this paper, we propose to use a two-layer hierarchical smoking detection algorithm (HLSDA) that uses a classifier at the first layer, followed by a lazy context-rule-based correction method that utilizes neighbouring segments to improve the detection. We evaluated our algorithm on a dataset of 45 hours collected over a three month period where 11 participants performed 17 hours (230 cigarettes) of smoking while sitting, standing, walking, and in a group conversation. The rest of 28 hours consists of other similar activities, such as eating, and drinking. We show that our algorithm improves recall as well as precision for smoking compared to a single layer classification approach. For smoking activity, we achieve an F-measure of 90-97% in person-dependent evaluations and 83-94% in person-independent evaluations. In most cases, our algorithm corrects up to 50% of the misclassified smoking segments. Our algorithm also improves the detection of eating and drinking in a similar way. We make our dataset and data logger publicly available for the reproducibility of our work.