Add comments and clean up code. Add header comments for functions.
raedwards, jnallard