Revise Main and MathUtils for lab