Added events detection

New functions and constants