Remove duplicated definitions, and PEP8-ing (tabs to spaces, etc.)