diff --git a/lib/allconfig.php b/lib/allconfig.php
new file mode 100644
index 0000000000000000000000000000000000000000..72aabf60793b8caf84cdd93e5760a022ce0de9b4
--- /dev/null
+++ b/lib/allconfig.php
@@ -0,0 +1,77 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ * 
+ */
+
+namespace OC;
+
+/**
+ * Class to combine all the configuration options ownCloud offers
+ */
+class AllConfig implements \OCP\IConfig {
+	/**
+	 * Sets a new system wide value
+	 * @param string $key the key of the value, under which will be saved
+	 * @param string $value the value that should be stored
+	 * @todo need a use case for this
+	 */
+// 	public function setSystemValue($key, $value) {
+// 		\OCP\Config::setSystemValue($key, $value);
+// 	}
+
+	/**
+	 * Looks up a system wide defined value
+	 * @param string $key the key of the value, under which it was saved
+	 * @return string the saved value
+	 */
+	public function getSystemValue($key) {
+		return \OCP\Config::getSystemValue($key, '');
+	}
+
+
+	/**
+	 * Writes a new app wide value
+	 * @param string $appName the appName that we want to store the value under
+	 * @param string $key the key of the value, under which will be saved
+	 * @param string $value the value that should be stored
+	 */
+	public function setAppValue($appName, $key, $value) {
+		\OCP\Config::setAppValue($appName, $key, $value);
+	}
+
+	/**
+	 * Looks up an app wide defined value
+	 * @param string $appName the appName that we stored the value under
+	 * @param string $key the key of the value, under which it was saved
+	 * @return string the saved value
+	 */
+	public function getAppValue($appName, $key) {
+		return \OCP\Config::getAppValue($appName, $key, '');
+	}
+
+
+	/**
+	 * Set a user defined value
+	 * @param string $userId the userId of the user that we want to store the value under
+	 * @param string $appName the appName that we want to store the value under
+	 * @param string $key the key under which the value is being stored
+	 * @param string $value the value that you want to store
+	 */
+	public function setUserValue($userId, $appName, $key, $value) {
+		\OCP\Config::setUserValue($userId, $appName, $key, $value);
+	}
+
+	/**
+	 * Shortcut for getting a user defined value
+	 * @param string $userId the userId of the user that we want to store the value under
+	 * @param string $appName the appName that we stored the value under
+	 * @param string $key the key under which the value is being stored
+	 */
+	public function getUserValue($userId, $appName, $key){
+		return \OCP\Config::getUserValue($userId, $appName, $key);
+	}
+}
diff --git a/lib/app.php b/lib/app.php
index d98af2dc29688956d2a531a5851973b2ccd65299..0ab1ee57f631654cffcde66de4040b78ac23550e 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -27,8 +27,6 @@
  * upgrading and removing apps.
  */
 class OC_App{
-	static private $activeapp = '';
-	static private $navigation = array();
 	static private $settingsForms = array();
 	static private $adminForms = array();
 	static private $personalForms = array();
@@ -271,7 +269,7 @@ class OC_App{
 
 	/**
 	 * @brief adds an entry to the navigation
-	 * @param string $data array containing the data
+	 * @param array $data array containing the data
 	 * @return bool
 	 *
 	 * This function adds a new entry to the navigation visible to users. $data
@@ -287,11 +285,7 @@ class OC_App{
 	 *     the navigation. Lower values come first.
 	 */
 	public static function addNavigationEntry( $data ) {
-		$data['active']=false;
-		if(!isset($data['icon'])) {
-			$data['icon']='';
-		}
-		OC_App::$navigation[] = $data;
+		OC::$server->getNavigationManager()->add($data);
 		return true;
 	}
 
@@ -305,9 +299,7 @@ class OC_App{
 	 * highlighting the current position of the user.
 	 */
 	public static function setActiveNavigationEntry( $id ) {
-		// load all the apps, to make sure we have all the navigation entries
-		self::loadApps();
-		self::$activeapp = $id;
+		OC::$server->getNavigationManager()->setActiveEntry($id);
 		return true;
 	}
 
@@ -315,15 +307,14 @@ class OC_App{
 	 * @brief Get the navigation entries for the $app
 	 * @param string $app app
 	 * @return array of the $data added with addNavigationEntry
+	 *
+	 * Warning: destroys the existing entries
 	 */
 	public static function getAppNavigationEntries($app) {
 		if(is_file(self::getAppPath($app).'/appinfo/app.php')) {
-			$save = self::$navigation;
-			self::$navigation = array();
+			OC::$server->getNavigationManager()->clear();
 			require $app.'/appinfo/app.php';
-			$app_entries = self::$navigation;
-			self::$navigation = $save;
-			return $app_entries;
+			return OC::$server->getNavigationManager()->getAll();
 		}
 		return array();
 	}
@@ -336,7 +327,7 @@ class OC_App{
 	 * setActiveNavigationEntry
 	 */
 	public static function getActiveNavigationEntry() {
-		return self::$activeapp;
+		return OC::$server->getNavigationManager()->getActiveEntry();
 	}
 
 	/**
@@ -419,8 +410,9 @@ class OC_App{
 
 	// This is private as well. It simply works, so don't ask for more details
 	private static function proceedNavigation( $list ) {
+		$activeapp = OC::$server->getNavigationManager()->getActiveEntry();
 		foreach( $list as &$naventry ) {
-			if( $naventry['id'] == self::$activeapp ) {
+			if( $naventry['id'] == $activeapp ) {
 				$naventry['active'] = true;
 			}
 			else{
@@ -572,7 +564,8 @@ class OC_App{
 	 *   - active: boolean, signals if the user is on this navigation entry
 	 */
 	public static function getNavigation() {
-		$navigation = self::proceedNavigation( self::$navigation );
+		$entries = OC::$server->getNavigationManager()->getAll();
+		$navigation = self::proceedNavigation( $entries );
 		return $navigation;
 	}
 
diff --git a/lib/db/connection.php b/lib/db/connection.php
index 2581969dbd0a34a7a1ab3d61e381f49810943095..2d3193a148a46fa84cd38b31879612f22d64a708 100644
--- a/lib/db/connection.php
+++ b/lib/db/connection.php
@@ -12,7 +12,7 @@ use Doctrine\DBAL\Configuration;
 use Doctrine\DBAL\Cache\QueryCacheProfile;
 use Doctrine\Common\EventManager;
 
-class Connection extends \Doctrine\DBAL\Connection {
+class Connection extends \Doctrine\DBAL\Connection implements \OCP\IDBConnection {
 	/**
 	 * @var string $tablePrefix
 	 */
diff --git a/lib/navigationmanager.php b/lib/navigationmanager.php
new file mode 100644
index 0000000000000000000000000000000000000000..1f657b9ad80fd8b47edf0c381efd09132dd1ae15
--- /dev/null
+++ b/lib/navigationmanager.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+
+namespace OC;
+
+/**
+ * Manages the ownCloud navigation
+ */
+class NavigationManager implements \OCP\INavigationManager {
+	protected $entries = array();
+	protected $activeEntry;
+
+	/**
+	 * Creates a new navigation entry
+	 * @param array $entry containing: id, name, order, icon and href key
+	 */
+	public function add(array $entry) {
+		$entry['active'] = false;
+		if(!isset($entry['icon'])) {
+			$entry['icon'] = '';
+		}
+		$this->entries[] = $entry;
+	}
+
+	/**
+	 * @brief returns all the added Menu entries
+	 * @return array of the added entries
+	 */
+	public function getAll() {
+		return $this->entries;
+	}
+
+	/**
+	 * @brief removes all the entries
+	 */
+	public function clear() {
+		$this->entries = array();
+	}
+
+	/**
+	 * Sets the current navigation entry of the currently running app
+	 * @param string $id of the app entry to activate (from added $entry)
+	 */
+	public function setActiveEntry($id) {
+		$this->activeEntry = $id;
+	}
+
+	/**
+	 * @brief gets the active Menu entry
+	 * @return string id or empty string
+	 *
+	 * This function returns the id of the active navigation entry (set by
+	 * setActiveEntry
+	 */
+	public function getActiveEntry() {
+		return $this->activeEntry;
+	}
+}
diff --git a/lib/public/app.php b/lib/public/app.php
index a1ecf524cc84110440378a9452aad77b05068a49..0a5721b334e090413c7c9429795fa35d0c566b22 100644
--- a/lib/public/app.php
+++ b/lib/public/app.php
@@ -35,10 +35,10 @@ namespace OCP;
  */
 class App {
 	/**
-	 * @brief Makes owncloud aware of this app
+	 * @brief Makes ownCloud aware of this app
 	 * @brief This call is deprecated and not necessary to use.
 	 * @param $data array with all information
-	 * @returns true/false
+	 * @returns boolean
 	 *
 	 * @deprecated this method is deprecated
 	 * Do not call it anymore
@@ -52,7 +52,7 @@ class App {
 	/**
 	 * @brief adds an entry to the navigation
 	 * @param $data array containing the data
-	 * @returns true/false
+	 * @returns boolean
 	 *
 	 * This function adds a new entry to the navigation visible to users. $data
 	 * is an associative array.
@@ -72,8 +72,8 @@ class App {
 
 	/**
 	 * @brief marks a navigation entry as active
-	 * @param $id id of the entry
-	 * @returns true/false
+	 * @param $id string id of the entry
+	 * @returns boolean
 	 *
 	 * This function sets a navigation entry as active and removes the 'active'
 	 * property from all other entries. The templates can use this for
@@ -104,7 +104,7 @@ class App {
 	/**
 	 * @brief Read app metadata from the info.xml file
 	 * @param string $app id of the app or the path of the info.xml file
-	 * @param boolean path (optional)
+	 * @param boolean $path (optional)
 	 * @returns array
 	*/
 	public static function getAppInfo( $app, $path=false ) {
@@ -114,7 +114,7 @@ class App {
 	/**
 	 * @brief checks whether or not an app is enabled
 	 * @param $app app
-	 * @returns true/false
+	 * @returns boolean
 	 *
 	 * This function checks whether or not an app is enabled.
 	 */
@@ -133,7 +133,7 @@ class App {
 	/**
 	 * @brief Get the last version of the app, either from appinfo/version or from appinfo/info.xml
 	 * @param $app app
-	 * @returns true/false
+	 * @returns boolean
 	 */
 	public static function getAppVersion( $app ) {
 		return \OC_App::getAppVersion( $app );
diff --git a/lib/public/iconfig.php b/lib/public/iconfig.php
new file mode 100644
index 0000000000000000000000000000000000000000..850bddf6935fce77b22c71b597481f77fb67c8bb
--- /dev/null
+++ b/lib/public/iconfig.php
@@ -0,0 +1,65 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ * 
+ */
+
+namespace OCP;
+
+/**
+ * Access to all the configuration options ownCloud offers
+ */
+interface IConfig {
+	/**
+	 * Sets a new system wide value
+	 * @param string $key the key of the value, under which will be saved
+	 * @param string $value the value that should be stored
+	 * @todo need a use case for this
+	 */
+// 	public function setSystemValue($key, $value);
+
+	/**
+	 * Looks up a system wide defined value
+	 * @param string $key the key of the value, under which it was saved
+	 * @return string the saved value
+	 */
+	public function getSystemValue($key);
+
+
+	/**
+	 * Writes a new app wide value
+	 * @param string $appName the appName that we want to store the value under
+	 * @param string $key the key of the value, under which will be saved
+	 * @param string $value the value that should be stored
+	 */
+	public function setAppValue($appName, $key, $value);
+
+	/**
+	 * Looks up an app wide defined value
+	 * @param string $appName the appName that we stored the value under
+	 * @param string $key the key of the value, under which it was saved
+	 * @return string the saved value
+	 */
+	public function getAppValue($appName, $key);
+
+
+	/**
+	 * Set a user defined value
+	 * @param string $userId the userId of the user that we want to store the value under
+	 * @param string $appName the appName that we want to store the value under
+	 * @param string $key the key under which the value is being stored
+	 * @param string $value the value that you want to store
+	 */
+	public function setUserValue($userId, $appName, $key, $value);
+
+	/**
+	 * Shortcut for getting a user defined value
+	 * @param string $userId the userId of the user that we want to store the value under
+	 * @param string $appName the appName that we stored the value under
+	 * @param string $key the key under which the value is being stored
+	 */
+	public function getUserValue($userId, $appName, $key);
+}
diff --git a/lib/public/idbconnection.php b/lib/public/idbconnection.php
new file mode 100644
index 0000000000000000000000000000000000000000..c741a0f061ac19d49614c1bd547759e1e366ba87
--- /dev/null
+++ b/lib/public/idbconnection.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ * 
+ */
+
+namespace OCP;
+
+/**
+ * TODO: Description
+ */
+interface IDBConnection {
+	/**
+	 * Used to abstract the owncloud database access away
+	 * @param string $sql the sql query with ? placeholder for params
+	 * @param int $limit the maximum number of rows
+	 * @param int $offset from which row we want to start
+	 * @return \Doctrine\DBAL\Driver\Statement The prepared statement.
+	 */
+	public function prepare($sql, $limit=null, $offset=null);
+
+	/**
+	 * Used to get the id of the just inserted element
+	 * @param string $tableName the name of the table where we inserted the item
+	 * @return int the id of the inserted element
+	 */
+	public function lastInsertId($table = null);
+
+	/**
+	 * @brief Insert a row if a matching row doesn't exists.
+	 * @param $table string The table name (will replace *PREFIX*) to perform the replace on.
+	 * @param $input array
+	 *
+	 * The input array if in the form:
+	 *
+	 * array ( 'id' => array ( 'value' => 6,
+	 *	'key' => true
+	 *	),
+	 *	'name' => array ('value' => 'Stoyan'),
+	 *	'family' => array ('value' => 'Stefanov'),
+	 *	'birth_date' => array ('value' => '1975-06-20')
+	 *	);
+	 * @return bool
+	 *
+	 */
+	public function insertIfNotExist($table, $input);
+
+	/**
+	 * @brief Start a transaction
+	 * @return bool TRUE on success or FALSE on failure
+	 */
+	public function beginTransaction();
+
+	/**
+	 * @brief Commit the database changes done during a transaction that is in progress
+	 * @return bool TRUE on success or FALSE on failure
+	 */
+	public function commit();
+
+	/**
+	 * @brief Rollback the database changes done during a transaction that is in progress
+	 * @return bool TRUE on success or FALSE on failure
+	 */
+	public function rollBack();
+
+	/**
+	 * returns the error code and message as a string for logging
+	 * @return string
+	 */
+	public function getError();
+}
diff --git a/lib/public/inavigationmanager.php b/lib/public/inavigationmanager.php
new file mode 100644
index 0000000000000000000000000000000000000000..f89e790c1d0f6bbf70f8cf51db8a12c194781a83
--- /dev/null
+++ b/lib/public/inavigationmanager.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ * 
+ */
+
+namespace OCP;
+
+/**
+ * Manages the ownCloud navigation
+ */
+interface INavigationManager {
+	/**
+	 * Creates a new navigation entry
+	 * @param array $entry containing: id, name, order, icon and href key
+	 */
+	public function add(array $entry);
+
+	/**
+	 * Sets the current navigation entry of the currently running app
+	 * @param string $appId id of the app entry to activate (from added $entry)
+	 */
+	public function setActiveEntry($appId);
+}
diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php
index 1725b7c74e04bdd8d6c68495e6bae8312d57b191..4478a4e8a6cd47a61de766f8ea71105745d744c9 100644
--- a/lib/public/iservercontainer.php
+++ b/lib/public/iservercontainer.php
@@ -62,6 +62,23 @@ interface IServerContainer {
 	 */
 	function getRootFolder();
 
+	/**
+	 * Returns the user session
+	 *
+	 * @return \OCP\IUserSession
+	 */
+	function getUserSession();
+
+	/**
+	 * @return \OCP\INavigationManager
+	 */
+	function getNavigationManager();
+
+	/**
+	 * @return \OCP\IConfig
+	 */
+	function getConfig();
+
 	/**
 	 * Returns an ICache instance
 	 *
@@ -76,4 +93,11 @@ interface IServerContainer {
 	 */
 	function getSession();
 
+	/**
+	 * Returns the current session
+	 *
+	 * @return \OCP\IDBConnection
+	 */
+	function getDatabaseConnection();
+
 }
diff --git a/lib/public/iusersession.php b/lib/public/iusersession.php
new file mode 100644
index 0000000000000000000000000000000000000000..5dc1ecf71e647b14dba6676f5f6d59d2853e2687
--- /dev/null
+++ b/lib/public/iusersession.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ * 
+ */
+
+namespace OCP;
+
+/**
+ * User session
+ */
+interface IUserSession {
+	/**
+	 * Do a user login
+	 * @param string $user the username
+	 * @param string $password the password
+	 * @return bool true if successful
+	 */
+	public function login($user, $password);
+
+	/**
+	 * @brief Logs the user out including all the session data
+	 * Logout, destroys session
+	 */
+	public function logout();
+
+}
diff --git a/lib/server.php b/lib/server.php
index f4dc22a2be49da1f52078214bc8867aebcb7c959..804af6b0eac7cfc9a170ba8c317dfcf32e211264 100644
--- a/lib/server.php
+++ b/lib/server.php
@@ -4,6 +4,7 @@ namespace OC;
 
 use OC\AppFramework\Http\Request;
 use OC\AppFramework\Utility\SimpleContainer;
+use OC\Cache\UserCache;
 use OC\Files\Node\Root;
 use OC\Files\View;
 use OCP\IServerContainer;
@@ -49,13 +50,63 @@ class Server extends SimpleContainer implements IServerContainer {
 			return new PreviewManager();
 		});
 		$this->registerService('RootFolder', function($c) {
-			// TODO: get user and user manager from container as well
+			// TODO: get user from container as well
 			$user = \OC_User::getUser();
-			$user = \OC_User::getManager()->get($user);
+			/** @var $c SimpleContainer */
+			$userManager = $c->query('UserManager');
+			$user = $userManager->get($user);
 			$manager = \OC\Files\Filesystem::getMountManager();
 			$view = new View();
 			return new Root($manager, $view, $user);
 		});
+		$this->registerService('UserManager', function($c) {
+			return new \OC\User\Manager();
+		});
+		$this->registerService('UserSession', function($c) {
+			/** @var $c SimpleContainer */
+			$manager = $c->query('UserManager');
+			$userSession = new \OC\User\Session($manager, \OC::$session);
+			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
+				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
+			});
+			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
+				/** @var $user \OC\User\User */
+				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
+			});
+			$userSession->listen('\OC\User', 'preDelete', function ($user) {
+				/** @var $user \OC\User\User */
+				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
+			});
+			$userSession->listen('\OC\User', 'postDelete', function ($user) {
+				/** @var $user \OC\User\User */
+				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
+			});
+			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
+				/** @var $user \OC\User\User */
+				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
+			});
+			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
+				/** @var $user \OC\User\User */
+				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
+			});
+			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
+				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
+			});
+			$userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
+				/** @var $user \OC\User\User */
+				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
+			});
+			$userSession->listen('\OC\User', 'logout', function () {
+				\OC_Hook::emit('OC_User', 'logout', array());
+			});
+			return $userSession;
+		});
+		$this->registerService('NavigationManager', function($c) {
+			return new \OC\NavigationManager();
+		});
+		$this->registerService('AllConfig', function($c) {
+			return new \OC\AllConfig();
+		});
 		$this->registerService('UserCache', function($c) {
 			return new UserCache();
 		});
@@ -97,6 +148,33 @@ class Server extends SimpleContainer implements IServerContainer {
 		return $this->query('RootFolder');
 	}
 
+	/**
+	 * @return \OC\User\Manager
+	 */
+	function getUserManager() {
+		return $this->query('UserManager');
+	}
+
+	/**
+	 * @return \OC\User\Session
+	 */
+	function getUserSession() {
+		return $this->query('UserSession');
+	}
+
+	/**
+	 * @return \OC\NavigationManager
+	 */
+	function getNavigationManager() {
+		return $this->query('NavigationManager');
+	}
+
+	/**
+	 * @return \OC\Config
+	 */
+	function getConfig() {
+		return $this->query('AllConfig');
+	}
 	/**
 	 * Returns an ICache instance
 	 *
@@ -115,4 +193,12 @@ class Server extends SimpleContainer implements IServerContainer {
 		return \OC::$session;
 	}
 
+	/**
+	 * Returns the current session
+	 *
+	 * @return \OCP\IDBConnection
+	 */
+	function getDatabaseConnection() {
+		return \OC_DB::getConnection();
+	}
 }
diff --git a/lib/user.php b/lib/user.php
index 0f6f40aec9ae414fc0318f2d33ef1fa2bcb3de9f..7f6a296c3eaba6141e6d44e2853e901337727a5f 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -37,54 +37,15 @@
  *   logout()
  */
 class OC_User {
-	public static $userSession = null;
-
 	public static function getUserSession() {
-		if (!self::$userSession) {
-			$manager = new \OC\User\Manager();
-			self::$userSession = new \OC\User\Session($manager, \OC::$session);
-			self::$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
-				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
-			});
-			self::$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
-				/** @var $user \OC\User\User */
-				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
-			});
-			self::$userSession->listen('\OC\User', 'preDelete', function ($user) {
-				/** @var $user \OC\User\User */
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
-			});
-			self::$userSession->listen('\OC\User', 'postDelete', function ($user) {
-				/** @var $user \OC\User\User */
-				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
-			});
-			self::$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
-				/** @var $user \OC\User\User */
-				OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
-			});
-			self::$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
-				/** @var $user \OC\User\User */
-				OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
-			});
-			self::$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
-				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
-			});
-			self::$userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
-				/** @var $user \OC\User\User */
-				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
-			});
-			self::$userSession->listen('\OC\User', 'logout', function () {
-				\OC_Hook::emit('OC_User', 'logout', array());
-			});
-		}
-		return self::$userSession;
+		return OC::$server->getUserSession();
 	}
 
 	/**
 	 * @return \OC\User\Manager
 	 */
 	public static function getManager() {
-		return self::getUserSession()->getManager();
+		return OC::$server->getUserManager();
 	}
 
 	private static $_backends = array();
diff --git a/lib/user/session.php b/lib/user/session.php
index 9a6c669e935a8010c8c593c93a59f561c8a6df48..98a24d5bb00616ffa4e3dc376221041e17d45eaa 100644
--- a/lib/user/session.php
+++ b/lib/user/session.php
@@ -27,7 +27,7 @@ use OC\Hooks\Emitter;
  *
  * @package OC\User
  */
-class Session implements Emitter {
+class Session implements Emitter, \OCP\IUserSession {
 	/**
 	 * @var \OC\User\Manager $manager
 	 */