changed formatting and variable names to match standard and hopefully make the code easier to read. Merge with caution: example runs, but extensive tests not written yet