Add error detection to machine_types.py, reduce repitition of code