Clean up applescript; rewrote parser