Make internal functions static, reorder for simultaneous declaration. Reformat whitespace for readability.