Fixed open file issues permissions

Added more complete event handling system with callbacks