Revert "Moved stuff into main()"

This reverts commit aa728a34a304c92c3d92ac87609e4293813ad32b.
Added simple stop function