Yes this function smells at all. I'm currently working on it. However the patch is large so other parts can be reviewed while I'm working on it.