Added handler stack management. Closes #5, #6.