many changes to whitespace and naming for readability