Restructured internal code and added coloured output

Added functions to script to simplify logic, added coloured output,
redirected errors to STDERR, added exit through any non-zero code
Merge pull request #1 from cameronoxley/dev

Restructured internal code and added coloured output