Moved wireframe code out of main into separate functions (untested)