Correct handling for nested 'then' - Fixes #51