Moved scanner related functions into a seperate file.
Neatened up code in app.js.