removed unused functions, replace StandardError with Exception, fixed some PEP8 non compilant, replaced __dict__ asignations with setattr()