Fix issue #4

Some code changes, possibly not entirely correct, to fix #4 and another issue while parsing a simple file.