Fixed the problem of missed class/struct definitions by reading the whole file at once. Minor other refactoring and stylistic changes.