Magic numbers fix

Most of magic numbers in code have been replaced with defines.