changed some functions to defines
code improvements, reduced LOC