Fixed indentations, spaces, and lines; got rid of magic numbers; removed commented blocks of code; simplified some if conditions