Added import error prevention and removed some functions from misc.py