fixed defines, got rid of magic numbers