Utils misc patchset

This is a patchset for new functions and improve in utils_misc.py.