Added raise event in primitive callbacks
Replaced else if statements with switch statement