Index: kernel/generic/include/mm/as.h
===================================================================
--- kernel/generic/include/mm/as.h	(revision dad59517515e53c29f935bc4cbe535d802b998c0)
+++ kernel/generic/include/mm/as.h	(revision 80bcaed11c2e767559657092d6c13d1a7fdd449c)
@@ -54,5 +54,8 @@
 #include <lib/elf.h>
 
-/** Defined to be true if user address space and kernel address space shadow each other. */
+/**
+ * Defined to be true if user address space and kernel address space shadow each
+ * other.
+ */
 #define KERNEL_ADDRESS_SPACE_SHADOWED	KERNEL_ADDRESS_SPACE_SHADOWED_ARCH
 
@@ -62,15 +65,54 @@
 #define USER_ADDRESS_SPACE_END		USER_ADDRESS_SPACE_END_ARCH
 
-#define USTACK_ADDRESS	USTACK_ADDRESS_ARCH
-
-#define FLAG_AS_KERNEL	    (1 << 0)	/**< Kernel address space. */
-
-/** Address space area attributes. */
+#define USTACK_ADDRESS			USTACK_ADDRESS_ARCH
+
+/** Kernel address space. */
+#define FLAG_AS_KERNEL			(1 << 0)	
+
+/* Address space area attributes. */
 #define AS_AREA_ATTR_NONE	0
 #define AS_AREA_ATTR_PARTIAL	1	/**< Not fully initialized area. */
 
-#define AS_PF_FAULT		0	/**< The page fault was not resolved by as_page_fault(). */
-#define AS_PF_OK		1	/**< The page fault was resolved by as_page_fault(). */
-#define AS_PF_DEFER		2	/**< The page fault was caused by memcpy_from_uspace() or memcpy_to_uspace(). */
+/** The page fault was not resolved by as_page_fault(). */
+#define AS_PF_FAULT		0
+/** The page fault was resolved by as_page_fault(). */
+#define AS_PF_OK		1
+/** The page fault was caused by memcpy_from_uspace() or memcpy_to_uspace(). */
+#define AS_PF_DEFER		2
+
+/** Address space structure.
+ *
+ * as_t contains the list of as_areas of userspace accessible
+ * pages for one or more tasks. Ranges of kernel memory pages are not
+ * supposed to figure in the list as they are shared by all tasks and
+ * set up during system initialization.
+ */
+typedef struct as {
+	/** Protected by asidlock. */
+	link_t inactive_as_with_asid_link;
+
+	mutex_t lock;
+
+	/** Number of references (i.e tasks that reference this as). */
+	count_t refcount;
+
+	/** Number of processors on wich is this address space active. */
+	count_t cpu_refcount;
+
+	/** B+tree of address space areas. */
+	btree_t as_area_btree;
+	
+	/**
+	 *  Address space identifier.
+	 *  Constant on architectures that do not support ASIDs.
+	 */
+	asid_t asid;
+	
+	/** Non-generic content. */
+	as_genarch_t genarch;
+
+	/** Architecture specific content. */
+	as_arch_t arch;
+} as_t;
 
 typedef struct {
@@ -81,9 +123,17 @@
 } as_operations_t;
 
-/** This structure contains information associated with the shared address space area. */
+/**
+ * This structure contains information associated with the shared address space
+ * area.
+ */
 typedef struct {
-	mutex_t lock;		/**< This lock must be acquired only when the as_area lock is held. */
-	count_t refcount;	/**< This structure can be deallocated if refcount drops to 0. */
-	btree_t pagemap;	/**< B+tree containing complete map of anonymous pages of the shared area. */
+	/** This lock must be acquired only when the as_area lock is held. */
+	mutex_t lock;		
+	/** This structure can be deallocated if refcount drops to 0. */
+	count_t refcount;
+	/**
+	 * B+tree containing complete map of anonymous pages of the shared area.
+	 */
+	btree_t pagemap;
 } share_info_t;
 
@@ -116,13 +166,25 @@
 typedef struct {
 	mutex_t lock;
-	as_t *as;		/**< Containing address space. */
-	int flags;		/**< Flags related to the memory represented by the address space area. */
-	int attributes;		/**< Attributes related to the address space area itself. */
-	count_t pages;		/**< Size of this area in multiples of PAGE_SIZE. */
-	uintptr_t base;		/**< Base address of this area. */
-	btree_t used_space;	/**< Map of used space. */
-	share_info_t *sh_info;	/**< If the address space area has been shared, this pointer will
-			     	     reference the share info structure. */
-	struct mem_backend *backend;	/**< Memory backend backing this address space area. */
+	/** Containing address space. */
+	as_t *as;		
+	/** Flags related to the memory represented by the address space area. */
+	int flags;
+	/** Attributes related to the address space area itself. */
+	int attributes;
+	/** Size of this area in multiples of PAGE_SIZE. */
+	count_t pages;
+	/** Base address of this area. */
+	uintptr_t base;
+	/** Map of used space. */
+	btree_t used_space;
+
+	/**
+	 * If the address space area has been shared, this pointer will reference
+	 * the share info structure.
+	 */
+	share_info_t *sh_info;
+
+	/** Memory backend backing this address space area. */
+	struct mem_backend *backend;
 
 	/** Data to be used by the backend. */
@@ -147,13 +209,14 @@
 extern as_t *as_create(int flags);
 extern void as_destroy(as_t *as);
-extern void as_switch(as_t *old, as_t *replace);
+extern void as_switch(as_t *old_as, as_t *new_as);
 extern int as_page_fault(uintptr_t page, pf_access_t access, istate_t *istate);
 
-extern as_area_t *as_area_create(as_t *as, int flags, size_t size, uintptr_t base, int attrs,
-	mem_backend_t *backend, mem_backend_data_t *backend_data);
+extern as_area_t *as_area_create(as_t *as, int flags, size_t size,
+    uintptr_t base, int attrs, mem_backend_t *backend,
+    mem_backend_data_t *backend_data);
 extern int as_area_destroy(as_t *as, uintptr_t address);	
 extern int as_area_resize(as_t *as, uintptr_t address, size_t size, int flags);
 int as_area_share(as_t *src_as, uintptr_t src_base, size_t acc_size,
-		  as_t *dst_as, uintptr_t dst_base, int dst_flags_mask);
+    as_t *dst_as, uintptr_t dst_base, int dst_flags_mask);
 
 extern int as_area_get_flags(as_area_t *area);
Index: kernel/generic/include/mm/buddy.h
===================================================================
--- kernel/generic/include/mm/buddy.h	(revision dad59517515e53c29f935bc4cbe535d802b998c0)
+++ kernel/generic/include/mm/buddy.h	(revision 80bcaed11c2e767559657092d6c13d1a7fdd449c)
@@ -45,9 +45,13 @@
 /** Buddy system operations to be implemented by each implementation. */
 typedef struct {
-	/** Return pointer to left-side or right-side buddy for block passed as
-	  * argument. */
+	/**
+	 * Return pointer to left-side or right-side buddy for block passed as
+	 * argument.
+	 */
 	link_t *(* find_buddy)(struct buddy_system *, link_t *);
-	/** Bisect the block passed as argument and return pointer to the new
-	  * right-side buddy. */
+	/**
+	 * Bisect the block passed as argument and return pointer to the new
+	 * right-side buddy.
+	 */
 	link_t *(* bisect)(struct buddy_system *, link_t *);
 	/** Coalesce two buddies into a bigger block. */
@@ -76,5 +80,5 @@
 
 extern void buddy_system_create(buddy_system_t *b, uint8_t max_order,
-	buddy_system_operations_t *op, void *data);
+    buddy_system_operations_t *op, void *data);
 extern link_t *buddy_system_alloc(buddy_system_t *b, uint8_t i);
 extern bool buddy_system_can_alloc(buddy_system_t *b, uint8_t order);
Index: kernel/generic/include/mm/mm.h
===================================================================
--- kernel/generic/include/mm/mm.h	(revision dad59517515e53c29f935bc4cbe535d802b998c0)
+++ kernel/generic/include/mm/mm.h	(revision 80bcaed11c2e767559657092d6c13d1a7fdd449c)
@@ -47,18 +47,18 @@
 #define PAGE_GLOBAL_SHIFT		6
 
-#define PAGE_NOT_CACHEABLE	(0 << PAGE_CACHEABLE_SHIFT)
-#define PAGE_CACHEABLE		(1 << PAGE_CACHEABLE_SHIFT)
+#define PAGE_NOT_CACHEABLE		(0 << PAGE_CACHEABLE_SHIFT)
+#define PAGE_CACHEABLE			(1 << PAGE_CACHEABLE_SHIFT)
 
-#define PAGE_PRESENT		(0 << PAGE_PRESENT_SHIFT)
-#define PAGE_NOT_PRESENT	(1 << PAGE_PRESENT_SHIFT)
+#define PAGE_PRESENT			(0 << PAGE_PRESENT_SHIFT)
+#define PAGE_NOT_PRESENT		(1 << PAGE_PRESENT_SHIFT)
 
-#define PAGE_USER		(1 << PAGE_USER_SHIFT)
-#define PAGE_KERNEL		(0 << PAGE_USER_SHIFT)
+#define PAGE_USER			(1 << PAGE_USER_SHIFT)
+#define PAGE_KERNEL			(0 << PAGE_USER_SHIFT)
 
-#define PAGE_READ		(1 << PAGE_READ_SHIFT)
-#define PAGE_WRITE		(1 << PAGE_WRITE_SHIFT)
-#define PAGE_EXEC		(1 << PAGE_EXEC_SHIFT)
+#define PAGE_READ			(1 << PAGE_READ_SHIFT)
+#define PAGE_WRITE			(1 << PAGE_WRITE_SHIFT)
+#define PAGE_EXEC			(1 << PAGE_EXEC_SHIFT)
 
-#define PAGE_GLOBAL		(1 << PAGE_GLOBAL_SHIFT)
+#define PAGE_GLOBAL			(1 << PAGE_GLOBAL_SHIFT)
 
 #endif
Index: kernel/generic/include/mm/page.h
===================================================================
--- kernel/generic/include/mm/page.h	(revision dad59517515e53c29f935bc4cbe535d802b998c0)
+++ kernel/generic/include/mm/page.h	(revision 80bcaed11c2e767559657092d6c13d1a7fdd449c)
@@ -59,5 +59,5 @@
 extern void page_table_unlock(as_t *as, bool unlock);
 extern void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame,
-	int flags);
+    int flags);
 extern void page_mapping_remove(as_t *as, uintptr_t page);
 extern pte_t *page_mapping_find(as_t *as, uintptr_t page);
Index: kernel/generic/include/mm/slab.h
===================================================================
--- kernel/generic/include/mm/slab.h	(revision dad59517515e53c29f935bc4cbe535d802b998c0)
+++ kernel/generic/include/mm/slab.h	(revision 80bcaed11c2e767559657092d6c13d1a7fdd449c)
@@ -57,10 +57,16 @@
 
 /* slab_reclaim constants */
-#define SLAB_RECLAIM_ALL  0x1 /**< Reclaim all possible memory, because we are in memory stress */
+
+/** Reclaim all possible memory, because we are in memory stress */
+#define SLAB_RECLAIM_ALL  0x1 
 
 /* cache_create flags */
-#define SLAB_CACHE_NOMAGAZINE 0x1 /**< Do not use per-cpu cache */
-#define SLAB_CACHE_SLINSIDE   0x2 /**< Have control structure inside SLAB */
-#define SLAB_CACHE_MAGDEFERRED (0x4 | SLAB_CACHE_NOMAGAZINE) /**< We add magazine cache later, if we have this flag */
+
+/** Do not use per-cpu cache */
+#define SLAB_CACHE_NOMAGAZINE 0x1
+/** Have control structure inside SLAB */
+#define SLAB_CACHE_SLINSIDE   0x2
+/** We add magazine cache later, if we have this flag */
+#define SLAB_CACHE_MAGDEFERRED (0x4 | SLAB_CACHE_NOMAGAZINE)
 
 typedef struct {
@@ -82,9 +88,14 @@
 
 	link_t link;
+
 	/* Configuration */
-	size_t size;		/**< Size of slab position - align_up(sizeof(obj)) */
+	/** Size of slab position - align_up(sizeof(obj)) */
+	size_t size;
+
 	int (*constructor)(void *obj, int kmflag);
 	int (*destructor)(void *obj);
-	int flags;		/**< Flags changing behaviour of cache */
+
+	/** Flags changing behaviour of cache */
+	int flags;
 
 	/* Computed values */
@@ -96,5 +107,6 @@
 	atomic_t allocated_objs;
 	atomic_t cached_objs;
-	atomic_t magazine_counter; /**< How many magazines in magazines list */
+	/** How many magazines in magazines list */
+	atomic_t magazine_counter; 
 
 	/* Slabs */
@@ -110,10 +122,7 @@
 } slab_cache_t;
 
-extern slab_cache_t * slab_cache_create(char *name,
-					size_t size,
-					size_t align,
-					int (*constructor)(void *obj, int kmflag),
-					int (*destructor)(void *obj),
-					int flags);
+extern slab_cache_t * slab_cache_create(char *name, size_t size, size_t align,
+    int (*constructor)(void *obj, int kmflag), int (*destructor)(void *obj),
+    int flags);
 extern void slab_cache_destroy(slab_cache_t *cache);
 
@@ -122,5 +131,5 @@
 extern count_t slab_reclaim(int flags);
 
-/** Initialize slab subsytem */
+/* slab subsytem initialization */
 extern void slab_cache_init(void);
 extern void slab_enable_cpucache(void);
Index: kernel/generic/include/mm/tlb.h
===================================================================
--- kernel/generic/include/mm/tlb.h	(revision dad59517515e53c29f935bc4cbe535d802b998c0)
+++ kernel/generic/include/mm/tlb.h	(revision 80bcaed11c2e767559657092d6c13d1a7fdd449c)
@@ -40,6 +40,6 @@
 
 /**
- * Number of TLB shootdown messages that can be queued in processor
- * tlb_messages queue.
+ * Number of TLB shootdown messages that can be queued in processor tlb_messages
+ * queue.
  */
 #define TLB_MESSAGE_QUEUE_LEN	10
@@ -47,8 +47,12 @@
 /** Type of TLB shootdown message. */
 typedef enum {
-	TLB_INVL_INVALID = 0,		/**< Invalid type. */
-	TLB_INVL_ALL,			/**< Invalidate all entries in TLB. */
-	TLB_INVL_ASID,			/**< Invalidate all entries belonging to one address space. */
-	TLB_INVL_PAGES			/**< Invalidate specified page range belonging to one address space. */
+	/** Invalid type. */
+	TLB_INVL_INVALID = 0,
+	/** Invalidate all entries in TLB. */
+	TLB_INVL_ALL,
+	/** Invalidate all entries belonging to one address space. */
+	TLB_INVL_ASID,
+	/** Invalidate specified page range belonging to one address space. */
+	TLB_INVL_PAGES
 } tlb_invalidate_type_t;
 
@@ -64,11 +68,12 @@
 
 #ifdef CONFIG_SMP
-extern void tlb_shootdown_start(tlb_invalidate_type_t type, asid_t asid, uintptr_t page, count_t count);
+extern void tlb_shootdown_start(tlb_invalidate_type_t type, asid_t asid,
+    uintptr_t page, count_t count);
 extern void tlb_shootdown_finalize(void);
 extern void tlb_shootdown_ipi_recv(void);
 #else
-#  define tlb_shootdown_start(w, x, y, z)
-#  define tlb_shootdown_finalize()
-#  define tlb_shootdown_ipi_recv()
+#define tlb_shootdown_start(w, x, y, z)
+#define tlb_shootdown_finalize()
+#define tlb_shootdown_ipi_recv()
 #endif /* CONFIG_SMP */
 
