more refactoring
Use getChunkId() when reading/writing chunks