Fixed formatting, refactored some variables