Added namespace events and small re-factor