Do not crash on recursive alias functions

Fixes #473. Thanks to Dmitry Galchinsky (@galchinsky) for the fix.