Removed old unreachable code in misc_func
Fix a few syntax errors