Major refactoring. filemap format adjusted.