Cleanup code

Clean up directory structure of labs (change from labN/exM/input.c to labN/labN.M.c), simplify Makefiles, factor out common functions into separate source files, and change dynamic allocations using malloc() to static allocations where possible.