made functions more modular, and moved some defines into the config file