Another reorder of functions, now compiles, few warnings to fix.