more changes in PEP8 style and slight modifications in coding style and naming. More documentation of functions.