diff --git a/component/decorator/moopapi.logger.inc b/component/decorator/moopapi.logger.inc
index e69de29..8ade700 100644
--- a/component/decorator/moopapi.logger.inc
+++ b/component/decorator/moopapi.logger.inc
@@ -0,0 +1,147 @@
+<?php
+
+// @todo Make it configurable.
+define('LOGGER_DESTINATION', DRUPAL_ROOT . '/sites/default/files/botcha_logger.txt');
+
+/**
+ * Logger.
+ */
+abstract class Logger extends Decorator {
+  const LOGGER_DATE_FORMAT = 'Y/m/d H:i:s';
+  // A bitmask.
+  const LOGGER_DISABLED = 0;
+  const LOGGER_FILE = 1;  // 1 << 0 001
+  const LOGGER_DB = 2;    // 1 << 1 010
+  const LOGGER_EMAIL = 4; // 1 << 2 100
+
+  protected $date_format;
+  protected $destination;
+  protected $level;
+
+  public function __construct($decorators_applied = array(), &$relations = array(), $app) {
+    parent::__construct($decorators_applied, $relations, $app);
+    $this->setLevel(variable_get('botcha_logger_level', self::LOGGER_DISABLED));
+    $this->setDestination(variable_get('botcha_logger_destination', LOGGER_DESTINATION));
+    $this->setDateFormat(variable_get('botcha_logger_date_format', self::LOGGER_DATE_FORMAT));
+  }
+
+  public function setDateFormat($date_format) {
+    $this->date_format = $date_format;
+  }
+
+  public function getDateFormat() {
+    return $this->date_format;
+  }
+
+  public function setDestination($destination) {
+    $this->destination = $destination;
+  }
+
+  public function getDestination() {
+    return $this->destination;
+  }
+
+  public function setLevel($level) {
+    $this->level = $level;
+  }
+
+  public function getLevel() {
+    return $this->level;
+  }
+
+  protected function logCall($method, $arguments) {
+    $app = $this->original;
+    $class = get_class($app);
+    $this->log("!class::!method(!args) <=", array('!class' => $class, '!method' => $method, '!args' => print_r($arguments, TRUE)));
+    $return = call_user_func_array(array($app, $method), $arguments);
+    $this->log("!class::!method(!args) return !return", array('!class' => $class, '!method' => $method, '!args' => print_r($arguments, TRUE), '!return' => print_r($return, TRUE)));
+    return $return;
+  }
+
+  public function log($message, $placeholders) {
+    $levels = self::getLevels();
+    foreach ($levels as $level) {
+      if ($this->level & $level) {
+        $this->put2log($message, $placeholders);
+      }
+    }
+  }
+
+  protected static function getLevels() {
+    return array(
+      self::LOGGER_DISABLED,
+      self::LOGGER_FILE,
+      self::LOGGER_DB,
+      self::LOGGER_EMAIL,
+    );
+  }
+
+  protected function put2log($message, $placeholders = array()) {
+    $destination = NULL;
+    $extra_headers = NULL;
+    // Match corresponding log levels of error_log function.
+    $message_type = 0;
+    switch ($this->level) {
+      case self::LOGGER_FILE:
+        $message_type = 3;
+        $destination = $this->getDestination();
+        break;
+      case self::LOGGER_EMAIL:
+        $message_type = 1;
+        // @todo Real headers.
+        $extra_headers = NULL;
+      case self::LOGGER_DB:
+      default:
+        // Just use default logging behavior.
+        break;
+    }
+    error_log(date($this->date_format, time()) . ' ' .  t($message, $placeholders) . "\n", $message_type, $destination, $extra_headers);
+  }
+}
+
+
+abstract class ApplicationLogger extends Logger implements IApplication {
+  const ADMIN_PATH = 'admin';
+  protected $type = 'Application';
+  protected $ctrls = array();
+  protected $controllers = array();
+
+  public function __construct($decorators_applied = array(), &$relations = array(), $app) {
+    parent::__construct($decorators_applied, $relations, $app);
+    $this->getControllers();
+  }
+
+  public function getControllers() {
+    $controllers = array();
+    foreach ($this->ctrls as $ctrl_name) {
+      $controllers[$ctrl_name] = $this->getController($ctrl_name);
+    }
+    return $controllers;
+  }
+
+  protected function getController($ctrl_name) {
+    $this->controllers[$ctrl_name] = ComponentFactory::get($this->app_name, 'Controller', $ctrl_name, $this->decorators_applied, $this->relations);
+    return $this->controllers[$ctrl_name];
+  }
+}
+
+
+abstract class ControllerLogger extends Logger {
+  protected $type = 'Controller';
+  protected $model;
+
+  public function __construct($decorators_applied = array(), &$relations = array(), $app) {
+    parent::__construct($decorators_applied, $relations, $app);
+    $this->getModel();
+  }
+
+  protected function getModel() {
+    $this->model = ComponentFactory::get($this->app_name, 'Model', $this->controller_type, $this->decorators_applied, $this->relations);
+    return $this->model;
+  }
+}
+
+
+abstract class ModelLogger extends Logger {
+  protected $type = 'Model';
+}
\ No newline at end of file
diff --git a/component/moopapi.component.inc b/component/moopapi.component.inc
index e69de29..f667396 100644
--- a/component/moopapi.component.inc
+++ b/component/moopapi.component.inc
@@ -0,0 +1,225 @@
+<?php
+
+/**
+ * @todo Desc for Component.
+ */
+abstract class Component {
+  // It is intended to store the name of the module (for example, Botcha).
+  protected $app_name = '';
+  protected $decorators_applied = array();
+  // Identifier of a part of an application, each of which has
+  // its own controller and model. The main part of each application
+  // has id ID_APPLICATION - so we always know where to start.
+  protected $id = '';
+  const ID_APPLICATION = 'Application';
+  // In fact there are only 2 types: controller and model, we
+  // need a way to differ them.
+  protected $type = 'Component';
+  const TYPE_CONTROLLER = 'Controller';
+  const TYPE_MODEL = 'Model';
+  // For later use.
+  // @todo Implement relations.
+  // A list of relation names to be initialize at the first launch.
+  protected $rltns = array();
+  // Relations between parts of the application. Is intended to provide for
+  // controllers a way to get and modify common data accordingly.
+  protected $relations = array();
+
+  public function __construct($decorators_applied = array(), &$relations = array()) {
+    $this->decorators_applied = $decorators_applied;
+    $this->relations = &$relations;
+  }
+}
+
+
+/**
+ * An Abstract Factory for Components.
+ */
+abstract class ComponentFactory {
+  /**
+   *
+   * @param string $app_name
+   * @param string $type
+   * @param string $id
+   * @param array $decorators
+   * @return \decorator_class
+   */
+  public static function get($app_name, $type, $id, $decorators = array(), &$relations = array()) {
+    // Template of classname for replacings.
+    $class_pattern = '%app_name%id%type';
+    $class_search = array('%app_name', '%id', '%type');
+    // Switch to determine an object of which class to initialize.
+    switch ($id) {
+      case Component::ID_APPLICATION:
+        $class_replace = array($app_name, '', '');
+        break;
+      default:
+        $class_replace = array($app_name, $id, $type);
+        break;
+    }
+    $class = str_replace($class_search, $class_replace, $class_pattern);
+    $decorators_applied = $decorators;
+    $component = new $class($decorators_applied, $relations);
+    // Some preparations before building.
+    $app_name_lower = strtolower($app_name);
+    $type_lower = strtolower($type);
+    $id_lower = strtolower($id);
+    // Template of a file name with path for replacings.
+    $file_pattern = '%type/%id/decorator/%decorator/%app_name.%id.%type.%decorator';
+    $file_search = array('%type', '%id', '%decorator', '%app_name');
+    foreach ($decorators as $did => $decorator) {
+      $decorator_lower = strtolower($decorator);
+      // Switch to determine where to find a necessary file.
+      $file_replace = array($type_lower, $id_lower, $decorator_lower, $app_name_lower);
+      $file = str_replace($file_search, $file_replace, $file_pattern);
+      // Include necessary file.
+      module_load_include('inc', $app_name_lower, $file);
+      $decorator_class = $class . $decorator;
+      $component = new $decorator_class($decorators_applied, $relations, $component);
+      unset($decorators_applied[$did]);
+    }
+    return $component;
+  }
+}
+
+interface IApplication {
+  public function getControllers();
+  public function getAdminForm($form, &$form_state, $form_name);
+  public function submitAdminForm($form, &$form_state);
+}
+
+
+/**
+ * @todo Desc for Application.
+ */
+abstract class Application extends Component implements IApplication {
+  // The base path for all configurations.
+  const ADMIN_PATH = 'admin';
+  protected $type = 'Application';
+  // A list of controller names to be initialize at the first launch.
+  protected $ctrls = array();
+  // Controllers to manipulate the parts of the application as a whole.
+  protected $controllers = array();
+
+  public function __construct($decorators_applied = array()) {
+    parent::__construct($decorators_applied);
+    $this->getControllers();
+  }
+
+  public function getControllers() {
+    if (empty($this->controllers)) {
+      foreach ($this->ctrls as $ctrl_name) {
+        $this->controllers[$ctrl_name] = $this->getController($ctrl_name);
+      }
+    }
+    return $this->controllers;
+  }
+
+  protected function getController($ctrl_name) {
+    if (empty($this->controllers[$ctrl_name])) {
+      $controller = ComponentFactory::get($this->app_name, 'Controller', $ctrl_name, $this->decorators_applied, $this->relations);
+      $this->controllers[$ctrl_name] = $controller;
+    }
+    return $this->controllers[$ctrl_name];
+  }
+}
+
+
+abstract class Controller extends Component {
+  protected $type = 'Controller';
+  protected $model;
+
+  public function __construct($decorators_applied = array(), &$relations = array()) {
+    parent::__construct($decorators_applied, $relations);
+    $this->getModel();
+  }
+
+  protected function getModel() {
+    $this->model = ComponentFactory::get($this->app_name, 'Model', $this->controller_type, $this->decorators_applied, $this->relations);
+    return $this->model;
+  }
+}
+
+
+// @todo Real Model interface.
+interface IModel {}
+
+abstract class Model extends Component implements IModel {
+  protected $type = 'Model';
+
+  public function __construct($decorators_applied = array(), &$relations = array()) {
+    parent::__construct($decorators_applied, $relations);
+  }
+}
+
+
+/**
+ * Decorator.
+ * @see http://en.wikipedia.org/wiki/Decorator_pattern
+ */
+abstract class Decorator extends Component {
+  /**
+   * Here the original value of decorated application is stored.
+   * @var IApplication 
+   */
+  protected $original;
+
+  /**
+   * @param IApplication $app
+   */
+  public function __construct($decorators_applied = array(), &$relations = array(), $app) {
+    parent::__construct($decorators_applied, $relations);
+    $this->original = $app;
+  }
+}
+
+/* @todo Review.
+interface IRelationController {
+  public function getRelations();
+  public function getRelation($row);
+  public function setRelation($row);
+  public function save($relation);
+  public function delete($relation);
+}
+
+abstract class RelationController implements IRelationController {
+  public $table;
+  public $table_alias;
+  public $relations = array();
+
+  public function getRelations($reset = FALSE) {
+    if ($reset) {
+      $rtlns = db_select($this->table, $this->table_alias)
+        ->fields($this->table_alias)
+        ->execute();
+      while ($row = $rtlns->fetchObject()) {
+        $this->setRelation($row);
+      }
+    }
+    return $this->relations;
+  }
+
+  public function getRelation($row) {
+    $rowId = $this->getRowId($row);
+    if (empty($this->relations[$rowId])) {
+      $this->getRelations(TRUE);
+    }
+    return !empty($this->relations[$rowId]) ? $this->relations[$rowId] : NULL;
+  }
+
+  public function setRelation($row) {
+    $rowId = $this->getRowId($row);
+    $this->relations[$rowId] = $row;
+  }
+}
+
+interface IRelation {
+  public function __construct($row);
+}
+
+abstract class Relation implements IRelation {
+
+  public function __construct($row) {}
+}
+ *
+ */
\ No newline at end of file
diff --git a/moopapi.info b/moopapi.info
index 36d1f2f..84d4ce5 100644
--- a/moopapi.info
+++ b/moopapi.info
@@ -1,4 +1,9 @@
 name = Module Object Oriented Programming API
 description = Makes pure OOP syntax modules possible within the Drupal framework
-version = VERSION
-core = 6.x
\ No newline at end of file
+version = 1.x
+core = 7.x
+
+files[] = moopapi.install
+files[] = moopapi.module
+files[] = component/moopapi.component.inc
+files[] = component/decorator/moopapi.logger.inc
\ No newline at end of file
diff --git a/moopapi.install b/moopapi.install
index a8704cc..8158c27 100644
--- a/moopapi.install
+++ b/moopapi.install
@@ -1,5 +1,16 @@
 <?php
 
+/**
+ * @file
+ * Install, update and uninstall functions for the Moopapi module.
+ */
+
 function moopapi_enable() {
-  db_query('UPDATE {system} s SET weight = -1000 WHERE name = "moopapi"');
+  // @todo Abstract it.
+  //db_query('UPDATE {system} s SET weight = -1000 WHERE name = "moopapi"');
+  db_update('system')
+    ->fields(array('weight' => 1))
+    ->condition('type', 'module')
+    ->condition('name', 'moopapi')
+    ->execute();
 }
diff --git a/moopapi.module b/moopapi.module
index 83d8311..910ca6d 100644
--- a/moopapi.module
+++ b/moopapi.module
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * Implementation of hook_boot();
+ * Implements hook_boot().
  */
 function moopapi_boot() {
   /**
@@ -9,14 +9,15 @@ function moopapi_boot() {
    * All contrib oop modules will fail to execute properly if we fail to load this module before them.
    */
 }
+
 /**
- * Implementation of hook_init()
+ * Implements of hook_init().
  */
 function moopapi_init() {
   $classes = moopapi_register();    //fetch all registered classes
-  foreach ( $classes as $class ) {
+  foreach ($classes as $class) {
     $methods = get_class_methods($class);
-    foreach ($methods as $method ) {
+    foreach ($methods as $method) {
       moopapi_create_wrapper($class, $method);
     }
   }
@@ -29,7 +30,7 @@ function moopapi_init() {
  * @param method $method
  */
 function moopapi_create_wrapper($class, $method) {
-  if (in_array( $method, moopapi_hook_ignore_list())) {
+  if (in_array($method, moopapi_hook_ignore_list())) {
     /**
      * I am assuming that developer wants this method to be executed
      * Because developer explicitly implemented this hook both in function and in method.
@@ -40,7 +41,7 @@ function moopapi_create_wrapper($class, $method) {
     moopapi_object($class)->$method();
     return ;
   }
-  else if ( function_exists($class. '_'.$method)) {
+  elseif (function_exists($class . '_' . $method)) {
     /**
      * This could mean that developer chose to create function on his own, so we respect his wishes and skip re-implementing it
      * If in this step function does not exist it means that it was not created by the developer or previously by us.
@@ -55,43 +56,52 @@ function moopapi_create_wrapper($class, $method) {
    * to auto-discover certain properties, in this case number of arguments a method expects
    */
   $ref_method = new ReflectionMethod($class, $method);
-  $func_num_args = $ref_method->getNumberOfParameters();
-  $args_reference = moopapi_create_args($func_num_args, '&'); // arguments with    reference
-  $args_clean     = moopapi_create_args($func_num_args);      // arguments without reference
-
+  $parameters = $ref_method->getParameters();
+  $args = moopapi_create_args($parameters);
+  $args_clean = moopapi_create_args($parameters, TRUE);
   $function = "
-function {$class}_{$method}({$args_reference}) {
+function {$class}_{$method}({$args}) {
   return moopapi_object('{$class}')->$method({$args_clean});
 }";
   eval($function);    // This is what makes the magic possible create function in runtime that calls our objects
 }
+
 /**
- * API to create argument string of length
+ * API to create arguments' string.
  *
- * Example: $count = 3; $extra = '&'; => $args = '&arg0, &arg1, &arg2'
- *
- * @param int $count
- * @param string $extra
+ * @param array $parameters
+ * @param boolean $clean
  * @return arg_string
  */
-function moopapi_create_args($count, $extra = null) {
-  $args = '';
-  for( $i = 0 ; $i < $count; $i++ ) {
-    $args .= strlen($args) ? ', ' : '';
-    $args .= "{$extra}\$var{$i}";
+function moopapi_create_args($parameters, $clean = FALSE) {
+  $args = array();
+  foreach ($parameters as $i => $parameter) {
+    $prefix = '';
+    if (!$clean) {
+      $prefix = ($parameter->isPassedByReference()) ? '&' : '';
+    }
+    $args[$i] = "{$prefix}\$var{$i}";
   }
+  $args = implode(', ', $args);
   return $args;
 }
+
 /**
- * central pool of all of existent and loaded oop module objects
+ * Central pool of all of existent and loaded oop module objects.
  */
 function moopapi_object($class = NULL) {
   static $objects;
-  if ( $class !== NULL && !isset($objects[$class])) {
-    $objects[$class] = new $class();
+  if ($class !== NULL) {
+    // @todo Replace hardcode with a constant.
+    $class_lower = strtolower($class);
+    $new_object = ComponentFactory::get($class, Component::TYPE_CONTROLLER, Component::ID_APPLICATION, unserialize(variable_get("{$class_lower}_decorators", serialize(array()))));
+    if (!isset($objects[$class]) || get_class($objects[$class]) != get_class($new_object)) {
+      $objects[$class] = $new_object;
+    }
   }
   return $objects[$class];
 }
+
 /**
  * OOP modules must register themselves before they can be initialized
  * Modules can use this API function during boot and init hooks to register themselves so moopapi
@@ -99,18 +109,20 @@ function moopapi_object($class = NULL) {
  */
 function moopapi_register($class = NULL) {
   static $classes;
-  if ( !isset($classes) ) {
+  if (!isset($classes)) {
     $classes = array();
   }
-  if ( $class !== NULL && !isset($classes[$class])) {
-    $classes[$class] = $class;
+  if ($class !== NULL && !isset($classes[$class])) {
+    // Unify all classnames as follows: Application, Foo, Bar,...
+    $classes[ucfirst(strtolower($class))] = ucfirst(strtolower($class));
   }
   return $classes;
 }
 
 /**
- * return list of hooks which must not be created as wrappers
+ * Return list of hooks which must not be created as wrappers.
  */
 function moopapi_hook_ignore_list() {
   return array('boot');
-}
\ No newline at end of file
+}
+
