Move worker spawning into a function

Add cgmath as dependency