Index: uspace/lib/ext4/libext4_block_group.c
===================================================================
--- uspace/lib/ext4/libext4_block_group.c	(revision bed78cb7463a2984a9bebf02a464f951800654ef)
+++ uspace/lib/ext4/libext4_block_group.c	(revision f2eece1cca18bf0f3e1a61a3df9f63e5bac84254)
@@ -33,5 +33,5 @@
 /**
  * @file	libext4_block_group.c
- * @brief	Ext4 block group structure operations
+ * @brief	Ext4 block group structure operations.
  */
 
Index: uspace/lib/ext4/libext4_extent.c
===================================================================
--- uspace/lib/ext4/libext4_extent.c	(revision bed78cb7463a2984a9bebf02a464f951800654ef)
+++ uspace/lib/ext4/libext4_extent.c	(revision f2eece1cca18bf0f3e1a61a3df9f63e5bac84254)
@@ -933,6 +933,14 @@
 }
 
-/** TODO comment
- *
+/** Append data block to the i-node.
+ *
+ * This function allocates data block, tries to append it
+ * to some existing extent or creates new extents.
+ * It includes possible extent tree modifications (splitting).
+ *
+ * @param inode_ref			i-node to append block to
+ * @param iblock			output logical number of newly allocated block
+ * @param fblock			output physical block address of newly allocated block
+ * @return					error code
  */
 int ext4_extent_append_block(ext4_inode_ref_t *inode_ref,
@@ -968,5 +976,5 @@
 	}
 
-	// Add new extent to the node
+	// Add new extent to the node if not present
 	if (path_ptr->extent == NULL) {
 		goto append_extent;
@@ -979,5 +987,9 @@
 	if (block_count < block_limit) {
 
+		// There is space for new block in the extent
+
 		if (block_count == 0) {
+
+			// Existing extent is empty
 
 			rc = ext4_balloc_alloc_block(inode_ref, &phys_block);
@@ -986,8 +998,10 @@
 			}
 
+			// Initialize extent
 			ext4_extent_set_first_block(path_ptr->extent, new_block_idx);
 			ext4_extent_set_start(path_ptr->extent, phys_block);
 			ext4_extent_set_block_count(path_ptr->extent, 1);
 
+			// Update i-node
 			ext4_inode_set_size(inode_ref->inode, inode_size + block_size);
 			inode_ref->dirty = true;
@@ -998,7 +1012,10 @@
 		} else {
 
+			// Existing extent contains some blocks
+
 			phys_block = ext4_extent_get_start(path_ptr->extent);
 			phys_block += ext4_extent_get_block_count(path_ptr->extent);
 
+			// Check if the following block is free for allocation
 			bool free;
 			rc = ext4_balloc_try_alloc_block(inode_ref, phys_block, &free);
@@ -1008,11 +1025,13 @@
 
 			if (! free) {
-				// target is not free
+				// target is not free, new block must be appended to new extent
 				goto append_extent;
 			}
 
 
+			// Update extent
 			ext4_extent_set_block_count(path_ptr->extent, block_count + 1);
 
+			// Update i-node
 			ext4_inode_set_size(inode_ref->inode, inode_size + block_size);
 			inode_ref->dirty = true;
@@ -1024,8 +1043,10 @@
 	}
 
+// Append new extent to the tree
 append_extent:
 
 	phys_block = 0;
-	// Allocate and insert insert new block
+
+	// Allocate new data block
 	rc = ext4_balloc_alloc_block(inode_ref, &phys_block);
 	if (rc != EOK) {
@@ -1034,4 +1055,5 @@
 	}
 
+	// Append extent for new block (includes tree splitting if needed)
 	rc = ext4_extent_append_extent(inode_ref, path, &path_ptr, new_block_idx);
 	if (rc != EOK) {
@@ -1040,8 +1062,10 @@
 	}
 
+	// Initialize newly created extent
 	ext4_extent_set_block_count(path_ptr->extent, 1);
 	ext4_extent_set_first_block(path_ptr->extent, new_block_idx);
 	ext4_extent_set_start(path_ptr->extent, phys_block);
 
+	// Update i-node
 	ext4_inode_set_size(inode_ref->inode, inode_size + block_size);
 	inode_ref->dirty = true;
@@ -1049,6 +1073,7 @@
 	path_ptr->block->dirty = true;
 
+
 finish:
-
+	// Set return values
 	*iblock = new_block_idx;
 	*fblock = phys_block;
Index: uspace/lib/ext4/libext4_filesystem.c
===================================================================
--- uspace/lib/ext4/libext4_filesystem.c	(revision bed78cb7463a2984a9bebf02a464f951800654ef)
+++ uspace/lib/ext4/libext4_filesystem.c	(revision f2eece1cca18bf0f3e1a61a3df9f63e5bac84254)
@@ -186,5 +186,5 @@
  * @param fs		filesystem to find block group on
  * @param bgid		index of block group to load
- * @oaram ref		output pointer for reference
+ * @param ref		output pointer for reference
  * @return			error code
  */
@@ -229,12 +229,20 @@
 }
 
-/** TODO comment
- *
+/** Compute checksum of block group descriptor.
+ *
+ * It uses crc functions from Linux kernel implementation.
+ *
+ * @param sb		superblock
+ * @param bgid		index of block group in the filesystem
+ * @param bg		block group to compute checksum for
+ * @return			checksum value
  */
 static uint16_t ext4_filesystem_bg_checksum(ext4_superblock_t *sb, uint32_t bgid,
                             ext4_block_group_t *bg)
 {
+	// If checksum not supported, 0 will be returned
 	uint16_t crc = 0;
 
+	// Compute the checksum only if the filesystem supports it
 	if (ext4_superblock_has_feature_read_only(sb, EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
 
@@ -244,13 +252,20 @@
 		uint32_t offset = (uint32_t)(checksum - base);
 
+		// Convert block group index to little endian
 		uint32_t le_group = host2uint32_t_le(bgid);
 
+		// Initialization
 		crc = crc16(~0, sb->uuid, sizeof(sb->uuid));
+
+		// Include index of block group
 		crc = crc16(crc, (uint8_t *)&le_group, sizeof(le_group));
+
+		// Compute crc from the first part (stop before checksum field)
 		crc = crc16(crc, (uint8_t *)bg, offset);
 
-		offset += sizeof(bg->checksum); /* skip checksum */
-
-		/* for checksum of struct ext4_group_desc do the rest...*/
+		// Skip checksum
+		offset += sizeof(bg->checksum);
+
+		// Checksum of the rest of block group descriptor
 		if ((ext4_superblock_has_feature_incompatible(sb, EXT4_FEATURE_INCOMPAT_64BIT)) &&
 			offset < ext4_superblock_get_desc_size(sb)) {
@@ -368,6 +383,8 @@
 }
 
-/** TODO comment
- *
+/** Put reference to i-node.
+ *
+ * @param ref		pointer for reference to be put back
+ * @return			error code
  */
 int ext4_filesystem_put_inode_ref(ext4_inode_ref_t *ref)
@@ -375,8 +392,12 @@
 	int rc;
 
+	// Check if reference modified
 	if (ref->dirty) {
+
+		// Mark block dirty for writing changes to physical device
 		ref->block->dirty = true;
 	}
 
+	// Put back block, that contains i-node
 	rc = block_put(ref->block);
 	free(ref);
@@ -385,6 +406,10 @@
 }
 
-/** TODO comment
- *
+/** Allocate new i-node in the filesystem.
+ *
+ * @param fs			filesystem to allocated i-node on
+ * @param inode_ref		output pointer to return reference to allocated i-node
+ * @param flags			flags to be set for newly created i-node
+ * @return				error code
  */
 int ext4_filesystem_alloc_inode(ext4_filesystem_t *fs,
@@ -393,4 +418,5 @@
 	int rc;
 
+	// Check if newly allocated i-node will be a directory
 	bool is_dir = false;
 	if (flags & L_DIRECTORY) {
@@ -398,5 +424,5 @@
 	}
 
-	// allocate inode
+	// Allocate inode by allocation algorithm
 	uint32_t index;
 	rc = ext4_ialloc_alloc_inode(fs, &index, is_dir);
@@ -405,4 +431,5 @@
 	}
 
+	// Load i-node from on-disk i-node table
 	rc = ext4_filesystem_get_inode_ref(fs, index, inode_ref);
 	if (rc != EOK) {
@@ -411,5 +438,5 @@
 	}
 
-	// init inode
+	// Initialize i-node
 	ext4_inode_t *inode = (*inode_ref)->inode;
 
@@ -438,4 +465,5 @@
 	}
 
+	// Initialize extents if needed
 	if (ext4_superblock_has_feature_incompatible(
 			fs->superblock, EXT4_FEATURE_INCOMPAT_EXTENTS)) {
@@ -461,6 +489,8 @@
 }
 
-/** TODO comment
- *
+/** Release i-node and mark it as free.
+ *
+ * @param inode_ref			i-node to be released
+ * @return					error code
  */
 int ext4_filesystem_free_inode(ext4_inode_ref_t *inode_ref)
@@ -470,4 +500,5 @@
 	ext4_filesystem_t *fs = inode_ref->fs;
 
+	// For extents must be data block destroyed by other way
 	if (ext4_superblock_has_feature_incompatible(
 			fs->superblock, EXT4_FEATURE_INCOMPAT_EXTENTS) &&
@@ -478,5 +509,5 @@
 	}
 
-	// release all indirect (no data) blocks
+	// Release all indirect (no data) blocks
 
 	// 1) Single indirect
@@ -583,7 +614,9 @@
 
 finish:
+
+	// Mark inode dirty for writing to the physical device
 	inode_ref->dirty = true;
 
-	// Free inode
+	// Free inode by allocator
 	if (ext4_inode_is_type(fs->superblock, inode_ref->inode,
 			EXT4_INODE_MODE_DIRECTORY)) {
@@ -599,6 +632,9 @@
 }
 
-/** TODO comment
- *
+/** Truncate i-node data blocks.
+ *
+ * @param inode_ref		i-node to be truncated
+ * @param new_size		new size of inode (must be < current size)
+ * @return				error code
  */
 int ext4_filesystem_truncate_inode(
@@ -609,20 +645,21 @@
 	ext4_superblock_t *sb = inode_ref->fs->superblock;
 
+	// Check flags, if i-node can be truncated
 	if (! ext4_inode_can_truncate(sb, inode_ref->inode)) {
-		// Unable to truncate
 		return EINVAL;
 	}
 
+	// If sizes are equal, nothing has to be done.
 	aoff64_t old_size = ext4_inode_get_size(sb, inode_ref->inode);
 	if (old_size == new_size) {
-		// Nothing to do
 		return EOK;
 	}
 
-	// It's not suppported to make the larger file
+	// It's not suppported to make the larger file by truncate operation
 	if (old_size < new_size) {
 		return EINVAL;
 	}
 
+	// Compute how many blocks will be released
 	aoff64_t size_diff = old_size - new_size;
 	uint32_t block_size  = ext4_superblock_get_block_size(sb);
@@ -641,4 +678,6 @@
 				ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS)) {
 
+		// Extents require special operation
+
 		rc = ext4_extent_release_blocks_from(inode_ref,
 				old_blocks_count - diff_blocks_count);
@@ -647,5 +686,8 @@
 		}
 	} else {
-		// starting from 1 because of logical blocks are numbered from 0
+
+		// Release data blocks from the end of file
+
+		// Starting from 1 because of logical blocks are numbered from 0
 		for (uint32_t i = 1; i <= diff_blocks_count; ++i) {
 			rc = ext4_filesystem_release_inode_block(inode_ref, old_blocks_count - i);
@@ -656,6 +698,6 @@
 	}
 
+	// Update i-node
 	ext4_inode_set_size(inode_ref->inode, new_size);
-
 	inode_ref->dirty = true;
 
@@ -663,6 +705,10 @@
 }
 
-/** TODO comment
- *
+/** Get physical block address by logical index of the block.
+ *
+ * @param inode_ref		i-node to read block address from
+ * @param iblock		logical index of block
+ * @param fblock		output pointer for return physical block address
+ * @return				error code
  */
 int ext4_filesystem_get_inode_data_block_index(ext4_inode_ref_t *inode_ref,
@@ -673,4 +719,5 @@
 	ext4_filesystem_t *fs = inode_ref->fs;
 
+	// For empty file is situation simple
 	if (ext4_inode_get_size(fs->superblock, inode_ref->inode) == 0) {
 		*fblock = 0;
@@ -680,7 +727,8 @@
 	uint32_t current_block;
 
-	/* Handle inode using extents */
+	// Handle i-node using extents
 	if (ext4_superblock_has_feature_incompatible(fs->superblock, EXT4_FEATURE_INCOMPAT_EXTENTS) &&
 			ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS)) {
+
 		rc = ext4_extent_find_block(inode_ref, iblock, &current_block);
 
@@ -696,8 +744,102 @@
 	ext4_inode_t *inode = inode_ref->inode;
 
-	/* Handle simple case when we are dealing with direct reference */
+	// Direct block are read directly from array in i-node structure
 	if (iblock < EXT4_INODE_DIRECT_BLOCK_COUNT) {
 		current_block = ext4_inode_get_direct_block(inode, (uint32_t)iblock);
 		*fblock = current_block;
+		return EOK;
+	}
+
+	// Determine indirection level of the target block
+	int level = -1;
+	for (int i = 1; i < 4; i++) {
+		if (iblock < fs->inode_block_limits[i]) {
+			level = i;
+			break;
+		}
+	}
+
+	if (level == -1) {
+		return EIO;
+	}
+
+	// Compute offsets for the topmost level
+	aoff64_t block_offset_in_level = iblock - fs->inode_block_limits[level-1];
+	current_block = ext4_inode_get_indirect_block(inode, level-1);
+	uint32_t offset_in_block = block_offset_in_level / fs->inode_blocks_per_level[level-1];
+
+	// Sparse file
+	if (current_block == 0) {
+		*fblock = 0;
+		return EOK;
+	}
+
+	block_t *block;
+
+	/* Navigate through other levels, until we find the block number
+	 * or find null reference meaning we are dealing with sparse file
+	 */
+	while (level > 0) {
+
+		// Load indirect block
+		rc = block_get(&block, fs->device, current_block, 0);
+		if (rc != EOK) {
+			return rc;
+		}
+
+		// Read block address from indirect block
+		current_block = uint32_t_le2host(((uint32_t*)block->data)[offset_in_block]);
+
+		// Put back indirect block untouched
+		rc = block_put(block);
+		if (rc != EOK) {
+			return rc;
+		}
+
+		// Check for sparse file
+		if (current_block == 0) {
+			*fblock = 0;
+			return EOK;
+		}
+
+		// Jump to the next level
+		level -= 1;
+
+		// Termination condition - we have address of data block loaded
+		if (level == 0) {
+			break;
+		}
+
+		// Visit the next level
+		block_offset_in_level %= fs->inode_blocks_per_level[level];
+		offset_in_block = block_offset_in_level / fs->inode_blocks_per_level[level-1];
+	}
+
+	*fblock = current_block;
+
+	return EOK;
+}
+
+/** TODO comment
+ *
+ */
+int ext4_filesystem_set_inode_data_block_index(ext4_inode_ref_t *inode_ref,
+		aoff64_t iblock, uint32_t fblock)
+{
+	int rc;
+
+	ext4_filesystem_t *fs = inode_ref->fs;
+
+	/* Handle inode using extents */
+	if (ext4_superblock_has_feature_compatible(fs->superblock, EXT4_FEATURE_INCOMPAT_EXTENTS) &&
+			ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS)) {
+		// not reachable !!!
+		return ENOTSUP;
+	}
+
+	/* Handle simple case when we are dealing with direct reference */
+	if (iblock < EXT4_INODE_DIRECT_BLOCK_COUNT) {
+		ext4_inode_set_direct_block(inode_ref->inode, (uint32_t)iblock, fblock);
+		inode_ref->dirty = true;
 		return EOK;
 	}
@@ -716,15 +858,40 @@
 	}
 
+	uint32_t block_size = ext4_superblock_get_block_size(fs->superblock);
+
 	/* Compute offsets for the topmost level */
 	aoff64_t block_offset_in_level = iblock - fs->inode_block_limits[level-1];
-	current_block = ext4_inode_get_indirect_block(inode, level-1);
+	uint32_t current_block = ext4_inode_get_indirect_block(inode_ref->inode, level-1);
 	uint32_t offset_in_block = block_offset_in_level / fs->inode_blocks_per_level[level-1];
 
+	uint32_t new_block_addr;
+	block_t *block, *new_block;
+
 	if (current_block == 0) {
-		*fblock = 0;
-		return EOK;
-	}
-
-	block_t *block;
+		rc = ext4_balloc_alloc_block(inode_ref, &new_block_addr);
+		if (rc != EOK) {
+			return rc;
+		}
+
+		ext4_inode_set_indirect_block(inode_ref->inode, level - 1, new_block_addr);
+
+		inode_ref->dirty = true;
+
+		rc = block_get(&new_block, fs->device, new_block_addr, BLOCK_FLAGS_NOREAD);
+		if (rc != EOK) {
+			ext4_balloc_free_block(inode_ref, new_block_addr);
+			return rc;
+		}
+
+		memset(new_block->data, 0, block_size);
+		new_block->dirty = true;
+
+		rc = block_put(new_block);
+		if (rc != EOK) {
+			return rc;
+		}
+
+		current_block = new_block_addr;
+	}
 
 	/* Navigate through other levels, until we find the block number
@@ -732,4 +899,5 @@
 	 */
 	while (level > 0) {
+
 		rc = block_get(&block, fs->device, current_block, 0);
 		if (rc != EOK) {
@@ -739,13 +907,39 @@
 		current_block = uint32_t_le2host(((uint32_t*)block->data)[offset_in_block]);
 
+		if ((level > 1) && (current_block == 0)) {
+			rc = ext4_balloc_alloc_block(inode_ref, &new_block_addr);
+			if (rc != EOK) {
+				block_put(block);
+				return rc;
+			}
+
+			rc = block_get(&new_block, fs->device, new_block_addr, BLOCK_FLAGS_NOREAD);
+			if (rc != EOK) {
+				block_put(block);
+				return rc;
+			}
+
+			memset(new_block->data, 0, block_size);
+			new_block->dirty = true;
+
+			rc = block_put(new_block);
+			if (rc != EOK) {
+				block_put(block);
+				return rc;
+			}
+
+			((uint32_t*)block->data)[offset_in_block] = host2uint32_t_le(new_block_addr);
+			block->dirty = true;
+			current_block = new_block_addr;
+		}
+
+		if (level == 1) {
+			((uint32_t*)block->data)[offset_in_block] = host2uint32_t_le(fblock);
+			block->dirty = true;
+		}
+
 		rc = block_put(block);
 		if (rc != EOK) {
 			return rc;
-		}
-
-		if (current_block == 0) {
-			/* This is a sparse file */
-			*fblock = 0;
-			return EOK;
 		}
 
@@ -764,6 +958,4 @@
 	}
 
-	*fblock = current_block;
-
 	return EOK;
 }
@@ -772,24 +964,32 @@
  *
  */
-int ext4_filesystem_set_inode_data_block_index(ext4_inode_ref_t *inode_ref,
-		aoff64_t iblock, uint32_t fblock)
-{
-	int rc;
+int ext4_filesystem_release_inode_block(
+		ext4_inode_ref_t *inode_ref, uint32_t iblock)
+{
+	int rc;
+
+	uint32_t fblock;
 
 	ext4_filesystem_t *fs = inode_ref->fs;
 
-	/* Handle inode using extents */
-	if (ext4_superblock_has_feature_compatible(fs->superblock, EXT4_FEATURE_INCOMPAT_EXTENTS) &&
-			ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS)) {
-		// not reachable !!!
-		return ENOTSUP;
-	}
+	// EXTENTS are handled otherwise
+	assert(! (ext4_superblock_has_feature_incompatible(fs->superblock,
+			EXT4_FEATURE_INCOMPAT_EXTENTS) &&
+			ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS)));
+
+	ext4_inode_t *inode = inode_ref->inode;
 
 	/* Handle simple case when we are dealing with direct reference */
 	if (iblock < EXT4_INODE_DIRECT_BLOCK_COUNT) {
-		ext4_inode_set_direct_block(inode_ref->inode, (uint32_t)iblock, fblock);
-		inode_ref->dirty = true;
-		return EOK;
-	}
+		fblock = ext4_inode_get_direct_block(inode, iblock);
+		// Sparse file
+		if (fblock == 0) {
+			return EOK;
+		}
+
+		ext4_inode_set_direct_block(inode, iblock, 0);
+		return ext4_balloc_free_block(inode_ref, fblock);
+	}
+
 
 	/* Determine the indirection level needed to get the desired block */
@@ -806,152 +1006,4 @@
 	}
 
-	uint32_t block_size = ext4_superblock_get_block_size(fs->superblock);
-
-	/* Compute offsets for the topmost level */
-	aoff64_t block_offset_in_level = iblock - fs->inode_block_limits[level-1];
-	uint32_t current_block = ext4_inode_get_indirect_block(inode_ref->inode, level-1);
-	uint32_t offset_in_block = block_offset_in_level / fs->inode_blocks_per_level[level-1];
-
-	uint32_t new_block_addr;
-	block_t *block, *new_block;
-
-	if (current_block == 0) {
-		rc = ext4_balloc_alloc_block(inode_ref, &new_block_addr);
-		if (rc != EOK) {
-			return rc;
-		}
-
-		ext4_inode_set_indirect_block(inode_ref->inode, level - 1, new_block_addr);
-
-		inode_ref->dirty = true;
-
-		rc = block_get(&new_block, fs->device, new_block_addr, BLOCK_FLAGS_NOREAD);
-		if (rc != EOK) {
-			ext4_balloc_free_block(inode_ref, new_block_addr);
-			return rc;
-		}
-
-		memset(new_block->data, 0, block_size);
-		new_block->dirty = true;
-
-		rc = block_put(new_block);
-		if (rc != EOK) {
-			return rc;
-		}
-
-		current_block = new_block_addr;
-	}
-
-	/* Navigate through other levels, until we find the block number
-	 * or find null reference meaning we are dealing with sparse file
-	 */
-	while (level > 0) {
-
-		rc = block_get(&block, fs->device, current_block, 0);
-		if (rc != EOK) {
-			return rc;
-		}
-
-		current_block = uint32_t_le2host(((uint32_t*)block->data)[offset_in_block]);
-
-		if ((level > 1) && (current_block == 0)) {
-			rc = ext4_balloc_alloc_block(inode_ref, &new_block_addr);
-			if (rc != EOK) {
-				block_put(block);
-				return rc;
-			}
-
-			rc = block_get(&new_block, fs->device, new_block_addr, BLOCK_FLAGS_NOREAD);
-			if (rc != EOK) {
-				block_put(block);
-				return rc;
-			}
-
-			memset(new_block->data, 0, block_size);
-			new_block->dirty = true;
-
-			rc = block_put(new_block);
-			if (rc != EOK) {
-				block_put(block);
-				return rc;
-			}
-
-			((uint32_t*)block->data)[offset_in_block] = host2uint32_t_le(new_block_addr);
-			block->dirty = true;
-			current_block = new_block_addr;
-		}
-
-		if (level == 1) {
-			((uint32_t*)block->data)[offset_in_block] = host2uint32_t_le(fblock);
-			block->dirty = true;
-		}
-
-		rc = block_put(block);
-		if (rc != EOK) {
-			return rc;
-		}
-
-		level -= 1;
-
-		/* If we are on the last level, break here as
-		 * there is no next level to visit
-		 */
-		if (level == 0) {
-			break;
-		}
-
-		/* Visit the next level */
-		block_offset_in_level %= fs->inode_blocks_per_level[level];
-		offset_in_block = block_offset_in_level / fs->inode_blocks_per_level[level-1];
-	}
-
-	return EOK;
-}
-
-/** TODO comment
- *
- */
-int ext4_filesystem_release_inode_block(
-		ext4_inode_ref_t *inode_ref, uint32_t iblock)
-{
-	int rc;
-
-	uint32_t fblock;
-
-	ext4_filesystem_t *fs = inode_ref->fs;
-
-	// EXTENTS are handled otherwise
-	assert(! (ext4_superblock_has_feature_incompatible(fs->superblock,
-			EXT4_FEATURE_INCOMPAT_EXTENTS) &&
-			ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS)));
-
-	ext4_inode_t *inode = inode_ref->inode;
-
-	/* Handle simple case when we are dealing with direct reference */
-	if (iblock < EXT4_INODE_DIRECT_BLOCK_COUNT) {
-		fblock = ext4_inode_get_direct_block(inode, iblock);
-		// Sparse file
-		if (fblock == 0) {
-			return EOK;
-		}
-
-		ext4_inode_set_direct_block(inode, iblock, 0);
-		return ext4_balloc_free_block(inode_ref, fblock);
-	}
-
-
-	/* Determine the indirection level needed to get the desired block */
-	int level = -1;
-	for (int i = 1; i < 4; i++) {
-		if (iblock < fs->inode_block_limits[i]) {
-			level = i;
-			break;
-		}
-	}
-
-	if (level == -1) {
-		return EIO;
-	}
-
 	/* Compute offsets for the topmost level */
 	aoff64_t block_offset_in_level = iblock - fs->inode_block_limits[level-1];
@@ -1006,6 +1058,10 @@
 }
 
-/** TODO comment
- *
+/** Append following logical block to the i-node.
+ *
+ * @param inode_ref			i-node to append block to
+ * @param fblock			output physical block address of newly allocated block
+ * @param iblock			output logical number of newly allocated block
+ * @return					error code
  */
 int ext4_filesystem_append_inode_block(ext4_inode_ref_t *inode_ref,
@@ -1031,10 +1087,13 @@
 	uint32_t block_size = ext4_superblock_get_block_size(sb);
 
-	// TODO zarovnat inode size a ne assert!!!
-	assert(inode_size % block_size == 0);
+	// Align size i-node size
+	if ((inode_size % block_size) != 0) {
+		inode_size += block_size - (inode_size % block_size);
+	}
 
 	// Logical blocks are numbered from 0
 	uint32_t new_block_idx = inode_size / block_size;
 
+	// Allocate new physical block
 	uint32_t phys_block;
 	rc =  ext4_balloc_alloc_block(inode_ref, &phys_block);
@@ -1043,4 +1102,5 @@
 	}
 
+	// Add physical block address to the i-node
 	rc = ext4_filesystem_set_inode_data_block_index(inode_ref, new_block_idx, phys_block);
 	if (rc != EOK) {
@@ -1049,15 +1109,18 @@
 	}
 
+	// Update i-node
 	ext4_inode_set_size(inode_ref->inode, inode_size + block_size);
-
 	inode_ref->dirty = true;
 
 	*fblock = phys_block;
 	*iblock = new_block_idx;
+
 	return EOK;
 }
 
-/** TODO comment
- *
+/** Add orphaned i-node to the orphans linked list.
+ *
+ * @param inode_ref		i-node to be added to orphans list
+ * @return				error code
  */
 int ext4_filesystem_add_orphan(ext4_inode_ref_t *inode_ref)
@@ -1065,5 +1128,9 @@
 	uint32_t next_orphan = ext4_superblock_get_last_orphan(
 			inode_ref->fs->superblock);
+
+	// Deletion time is used for holding next item of the list
 	ext4_inode_set_deletion_time(inode_ref->inode, next_orphan);
+
+	// Head of the list is in the superblock
 	ext4_superblock_set_last_orphan(
 			inode_ref->fs->superblock, inode_ref->index);
@@ -1073,6 +1140,8 @@
 }
 
-/** TODO comment
- *
+/** Delete orphaned i-node from the orphans linked list.
+ *
+ * @param inode_ref		i-node to be deleted from the orphans list
+ * @return				error code
  */
 int ext4_filesystem_delete_orphan(ext4_inode_ref_t *inode_ref)
@@ -1080,4 +1149,5 @@
 	int rc;
 
+	// Get head of the linked list
 	uint32_t last_orphan = ext4_superblock_get_last_orphan(
 			inode_ref->fs->superblock);
@@ -1086,4 +1156,5 @@
 	uint32_t next_orphan = ext4_inode_get_deletion_time(inode_ref->inode);
 
+	// Check if the head is the target
 	if (last_orphan == inode_ref->index) {
 		ext4_superblock_set_last_orphan(inode_ref->fs->superblock, next_orphan);
@@ -1098,9 +1169,13 @@
 		return rc;
 	}
+
 	next_orphan = ext4_inode_get_deletion_time(current->inode);
 
-	bool found;
-
+	bool found = false;
+
+	// Walk thourgh the linked list
 	while (next_orphan != 0) {
+
+		// Found?
 		if (next_orphan == inode_ref->index) {
 			next_orphan = ext4_inode_get_deletion_time(inode_ref->inode);
@@ -1121,5 +1196,7 @@
 	}
 
-	ext4_inode_set_deletion_time(inode_ref->inode, 0);
+	if (found) {
+		ext4_inode_set_deletion_time(inode_ref->inode, 0);
+	}
 
 	rc = ext4_filesystem_put_inode_ref(current);
