Split stuff into functions for readability.