Core: Re-implement loops, groups and tryMax stacks, close #1800