Recursive name generation. Fixes #206

A bit prettier than the code I pasted before ;)