Revamp stack handling