Code clean up and check that it would match the python code guide lines
fixed a date compare bug