Various Improvements

-Improved event generator.
-Added event detection.