make format recognition more restrictive
fixed possible segmentation fault
Merge pull request #1 from richardtitze/master

Fixes