Remodeled the core functions into an events dispatching class