Got rid of some magic constants and formatted some code