refactor + more fixes + input type checking and parsing

It's https://github.com/sutoiku/formula.js/pull/26 plus the proper type checking and parsing for all formulas and some more fixes.