Move function implementation closer to its definition

Signed-off-by: Kare Nuorteva <kare.nuorteva@reaktor.fi>