Fix Stackoverflow in standalone implementation