Made many changes to support version 3 files. Testing is needed.