Changed much of the code and trigger behaviour.