add main macro

Move definition of the ugly main() code to a macro for readability. Also
fix correct return value of program.