Fixed segfaults. Added main math section to Jianmin function.