fixed class for PEP and changed constants to class variables

I would like to use your class in my next project and I'd appreciate it if you could use my changes in your original class.