Split into two files. Add on-stop support