Refactor and pretty up the code.