lots of bug fixes, yet another new semantic for defining actions, and lots of optimization
still a work in progress...
updated to match latest changes