Update to actions. Added new functions.

Added If, Else, While, and Repeat functionality. Made actions smaller by
creating two new functions (handleCondition and doScript). Some variable
renamings.