Index: uspace/lib/ext4/libext4_directory.c
===================================================================
--- uspace/lib/ext4/libext4_directory.c	(revision f49638edbaaecc88a823b18ce28fe67eb9d3bd5b)
+++ uspace/lib/ext4/libext4_directory.c	(revision 8be96a012921a51d1df863ec231b4da721c73676)
@@ -75,10 +75,9 @@
 	    ext4_superblock_get_minor_rev_level(sb) < 5) {
 
-		return de->name_length;
-	}
-
-	return ((uint16_t)de->name_length_high) << 8 |
-	    ((uint16_t)de->name_length);
-
+		return ((uint16_t)de->name_length_high) << 8 |
+			    ((uint16_t)de->name_length);
+
+	}
+	return de->name_length;
 
 }
@@ -87,13 +86,11 @@
 		ext4_directory_entry_ll_t *de, uint16_t length)
 {
-
 	de->name_length = (length << 8) >> 8;
 
-	if (ext4_superblock_get_rev_level(sb) > 0 ||
-		    ext4_superblock_get_minor_rev_level(sb) >= 5) {
+	if (ext4_superblock_get_rev_level(sb) == 0 &&
+		    ext4_superblock_get_minor_rev_level(sb) < 5) {
 
 		de->name_length_high = length >> 8;
 	}
-
 }
 
@@ -243,62 +240,87 @@
 
 
+int ext4_directory_find_entry(ext4_directory_iterator_t *it,
+		ext4_inode_ref_t *parent, const char *name)
+{
+	int rc;
+	uint32_t name_size = strlen(name);
+
+	// Index search
+	if (ext4_superblock_has_feature_compatible(it->fs->superblock, EXT4_FEATURE_COMPAT_DIR_INDEX) &&
+			ext4_inode_has_flag(parent->inode, EXT4_INODE_FLAG_INDEX)) {
+
+		rc = ext4_directory_dx_find_entry(it, it->fs, parent, name_size, name);
+
+		// Check if index is not corrupted
+		if (rc != EXT4_ERR_BAD_DX_DIR) {
+
+			if (rc != EOK) {
+				return rc;
+			}
+			return EOK;
+		}
+
+		EXT4FS_DBG("index is corrupted - doing linear search");
+	}
+
+	bool found = false;
+	// Linear search
+	while (it->current != NULL) {
+		uint32_t inode = ext4_directory_entry_ll_get_inode(it->current);
+
+		/* ignore empty directory entries */
+		if (inode != 0) {
+			uint16_t entry_name_size = ext4_directory_entry_ll_get_name_length(
+					it->fs->superblock, it->current);
+
+			if (entry_name_size == name_size && bcmp(name, it->current->name,
+				    name_size) == 0) {
+				found = true;
+				break;
+			}
+		}
+
+		rc = ext4_directory_iterator_next(it);
+		if (rc != EOK) {
+			return rc;
+		}
+	}
+
+	if (!found) {
+		return ENOENT;
+	}
+
+	return EOK;
+}
+
+
 int ext4_directory_remove_entry(ext4_filesystem_t* fs,
-		ext4_inode_ref_t *inode_ref, const char *name)
-{
-
-	// TODO modify HTREE index if exists
-
+		ext4_inode_ref_t *parent, const char *name)
+{
 	int rc;
 	ext4_directory_iterator_t it;
 
-	rc = ext4_directory_iterator_init(&it, fs, inode_ref, 0);
+	if (!ext4_inode_is_type(fs->superblock, parent->inode,
+	    EXT4_INODE_MODE_DIRECTORY)) {
+		return ENOTDIR;
+	}
+
+	rc = ext4_directory_iterator_init(&it, fs, parent, 0);
 	if (rc != EOK) {
 		return rc;
 	}
 
-	uint16_t name_size = strlen(name);
-	bool found = false;
-
-	while (it.current != NULL) {
-
-		if (it.current->inode == 0) {
-			goto skip;
-		}
-
-		uint16_t entry_name_size = ext4_directory_entry_ll_get_name_length(
-		    fs->superblock, it.current);
-
-		/* skip . and .. */
-		if (entry_name_size == 1 && name[0] == '.') {
-			goto skip;
-		}
-
-		if (entry_name_size == 2 && name[0] == '.' && name[1] == '.') {
-			goto skip;
-		}
-
-		if (name_size == entry_name_size &&
-				bcmp(name, &it.current->name, name_size) == 0) {
-
-			found = true;
-			break;
-		}
-
-skip:
-		rc = ext4_directory_iterator_next(&it);
-		if (rc != EOK) {
-			ext4_directory_iterator_fini(&it);
-			return rc;
-		}
-	}
-
-	if (! found) {
-		rc = ext4_directory_iterator_fini(&it);
-		if (rc != EOK) {
-			return rc;
-		}
-		return ENOENT;
-	}
-
+	rc = ext4_directory_find_entry(&it, parent, name);
+	if (rc != EOK) {
+		ext4_directory_iterator_fini(&it);
+		return rc;
+	}
+
+	if (rc != EOK) {
+		ext4_directory_iterator_fini(&it);
+		return rc;
+	}
+
+	// TODO modify HTREE index if exists
 
 	uint32_t block_size = ext4_superblock_get_block_size(fs->superblock);
Index: uspace/lib/ext4/libext4_directory.h
===================================================================
--- uspace/lib/ext4/libext4_directory.h	(revision f49638edbaaecc88a823b18ce28fe67eb9d3bd5b)
+++ uspace/lib/ext4/libext4_directory.h	(revision 8be96a012921a51d1df863ec231b4da721c73676)
@@ -77,9 +77,11 @@
 		ext4_filesystem_t *, ext4_inode_ref_t *, aoff64_t);
 extern int ext4_directory_iterator_next(ext4_directory_iterator_t *);
-extern int ext4_directory_iterator_seek(ext4_directory_iterator_t *, aoff64_t pos);
+extern int ext4_directory_iterator_seek(ext4_directory_iterator_t *, aoff64_t);
 extern int ext4_directory_iterator_fini(ext4_directory_iterator_t *);
 
+extern int ext4_directory_find_entry(ext4_directory_iterator_t *,
+		ext4_inode_ref_t *, const char *);
 extern int ext4_directory_remove_entry(ext4_filesystem_t* ,
-		ext4_inode_ref_t *, const char *name);
+		ext4_inode_ref_t *, const char *);
 
 #endif
Index: uspace/srv/fs/ext4fs/ext4fs_ops.c
===================================================================
--- uspace/srv/fs/ext4fs/ext4fs_ops.c	(revision f49638edbaaecc88a823b18ce28fe67eb9d3bd5b)
+++ uspace/srv/fs/ext4fs/ext4fs_ops.c	(revision 8be96a012921a51d1df863ec231b4da721c73676)
@@ -205,8 +205,4 @@
 	ext4_directory_iterator_t it;
 	int rc;
-	size_t name_size;
-	size_t component_size;
-	bool found = false;
-	uint32_t inode;
 
 	fs = eparent->instance->filesystem;
@@ -217,27 +213,4 @@
 	}
 
-	component_size = strlen(component);
-
-	if (ext4_superblock_has_feature_compatible(fs->superblock, EXT4_FEATURE_COMPAT_DIR_INDEX) &&
-			ext4_inode_has_flag(eparent->inode_ref->inode, EXT4_INODE_FLAG_INDEX)) {
-
-		rc = ext4_directory_dx_find_entry(&it, fs, eparent->inode_ref, component_size, component);
-
-		// Index isn't corrupted
-		if (rc != EXT4_ERR_BAD_DX_DIR) {
-
-			if (rc != EOK) {
-				return rc;
-			}
-
-			inode = ext4_directory_entry_ll_get_inode(it.current);
-
-			rc = ext4fs_node_get_core(rfn, eparent->instance, inode);
-			ext4_directory_iterator_fini(&it);
-			return rc;
-		}
-
-	}
-
 	rc = ext4_directory_iterator_init(&it, fs, eparent->inode_ref, 0);
 	if (rc != EOK) {
@@ -245,38 +218,19 @@
 	}
 
-	while (it.current != NULL) {
-		inode = ext4_directory_entry_ll_get_inode(it.current);
-
-		/* ignore empty directory entries */
-		if (inode != 0) {
-			name_size = ext4_directory_entry_ll_get_name_length(fs->superblock,
-				it.current);
-
-			if (name_size == component_size && bcmp(component, &it.current->name,
-				    name_size) == 0) {
-				rc = ext4fs_node_get_core(rfn, eparent->instance,
-					inode);
-				if (rc != EOK) {
-					ext4_directory_iterator_fini(&it);
-					return rc;
-				}
-				found = true;
-				break;
-			}
-		}
-
-		rc = ext4_directory_iterator_next(&it);
-		if (rc != EOK) {
-			ext4_directory_iterator_fini(&it);
-			return rc;
-		}
+	rc = ext4_directory_find_entry(&it, eparent->inode_ref, component);
+	if (rc != EOK) {
+		ext4_directory_iterator_fini(&it);
+		return rc;
+	}
+
+	uint32_t inode = ext4_directory_entry_ll_get_inode(it.current);
+
+	rc = ext4fs_node_get_core(rfn, eparent->instance, inode);
+	if (rc != EOK) {
+		ext4_directory_iterator_fini(&it);
+		return rc;
 	}
 
 	ext4_directory_iterator_fini(&it);
-
-	if (!found) {
-		return ENOENT;
-	}
-
 	return EOK;
 }
@@ -791,5 +745,4 @@
     ext4fs_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes)
 {
-
 	ext4_directory_iterator_t it;
 	aoff64_t next;
@@ -1151,8 +1104,14 @@
 static int ext4fs_destroy(service_id_t service_id, fs_index_t index)
 {
-	EXT4FS_DBG("not supported");
-
-	//TODO
-	return ENOTSUP;
+	int rc;
+	fs_node_t *fn;
+
+	rc = ext4fs_node_get(&fn, service_id, index);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	/* Destroy the inode */
+	return ext4fs_destroy_node(fn);
 }
 
