Done some radical changes in functions and expressions.
Added for loops, improved several small things