wrapping main in a self executing function as we're returning from non-functions (keeping IDE lint happy)
tidying up the bail approach
jshint is also happy (devil makes work for idle hands!)