Fixed ws in filename separator issue
Added minimal header checking, refactoring