Prefer linux's changes

Made a few changes to get everything working – $con to $db; staff to editor; that kind of thing.
Also did some modularisation.
Will add comments to lines when I can...