Added closest function.
More plans.
WIP move function definitions to own line.