Cleanup whitespace and repeated function calls