optimize code, documentation and add an Event system