Extending form management

1) I added some OnBefore and OnAfter functions to allow easier manipulation
2) changed $data variable from call by value to call by reference, maybe a BC issue but I think it makes sense. The possible BC problem can be that when someone wrote a plugin and changed the $data in it, then it is after the change **working** as expected, before the change it doesn't