Some code rewritten to be pretty