Make misc.py refactoring