Add 'main' function to all source files. Correct minor compilation errors caused by newer version of GHC.