Some small buds that I hope I have corrected.
Also making it possible to run it from main(....)