Bug fixed and events added

First events added.
Many bug fixed