event based rewrite

small core with everything going through events