removed some magic numbers and extra defines