Merge pull request #1 from esonderegger/master

first round of refactoring
Fixed crash when handed corrupt or incomplete file.
Fixed crash on incomplete & corrupt files
Update neg23.py
Merge pull request #1 from kylophone/master

sync from master