Finished refactored tern except the lgrindfile underscore problem.