Begin code cleanup and optimizations

Begin refactor or georef.cpp (was georef.c). Changed some heap memory allocations to stack based.