added def guards to scan.h

also cleaned up q2 main function a bit