Cleaned up some magic numbers and removed some unnecessary code