Refactor and Style some code