Move some meshing code into seperate file.