Improve project detection handling in the backend, add event "project.define"