minor refactoring and added .gitignore for .pyc files