Made the event reactor more efficient and added some maths utilities