Initial conversion of build system to non-recursive build. Fix compile-time errors and warnings.