Separate rendering from main code.