Fix bug - exception when transform input from string to int. Fix typo.
Fix more bugs.
Refine exception catching.