Reformated to fill among others PEP-8.
Changed possible internal keyword clashes. Added more comment fields.
Changed messages to use logging.