move all the global variables to defines.go; move pattern related code to patterns.go