Changing reset to clear
portability and valid number check

According to http://tldp.org/LDP/abs/html/portabilityissues.html
declaring functions this way is more portable