 core/authorize.php                                 |   53 +-
 core/cron.php                                      |   13 +-
 .../Drupal/Cache/CacheBackendInterface.php         |   14 +-
 core/includes/Drupal/Cache/DatabaseBackend.php     |   49 +-
 core/includes/Drupal/Cache/InstallBackend.php      |    3 +-
 core/includes/Drupal/Cache/NullBackend.php         |    4 +-
 core/includes/actions.inc                          |   21 +-
 core/includes/ajax.inc                             |   56 +-
 core/includes/archiver.inc                         |    1 +
 core/includes/authorize.inc                        |   15 +-
 core/includes/batch.inc                            |   59 +-
 core/includes/batch.queue.inc                      |    5 +-
 core/includes/bootstrap.inc                        |  514 +++++-----
 core/includes/cache.inc                            |    2 +
 core/includes/common.inc                           | 1006 ++++++++++----------
 core/includes/database/database.inc                |   12 +-
 core/includes/database/log.inc                     |    1 +
 core/includes/database/mysql/database.inc          |    2 +
 core/includes/database/mysql/install.inc           |    2 +
 core/includes/database/mysql/query.inc             |    1 +
 core/includes/database/mysql/schema.inc            |    2 +
 core/includes/database/pgsql/database.inc          |    2 +
 core/includes/database/pgsql/install.inc           |    2 +
 core/includes/database/pgsql/query.inc             |    2 +
 core/includes/database/pgsql/schema.inc            |    2 +
 core/includes/database/pgsql/select.inc            |    1 +
 core/includes/database/prefetch.inc                |    2 +
 core/includes/database/query.inc                   |    2 +
 core/includes/database/schema.inc                  |    4 +-
 core/includes/database/select.inc                  |   10 +-
 core/includes/database/sqlite/database.inc         |    4 +-
 core/includes/database/sqlite/install.inc          |    3 +-
 core/includes/database/sqlite/query.inc            |    1 +
 core/includes/database/sqlite/schema.inc           |    6 +-
 core/includes/database/sqlite/select.inc           |    1 +
 core/includes/date.inc                             |    1 +
 core/includes/errors.inc                           |   50 +-
 core/includes/file.inc                             |  121 ++--
 core/includes/file.mimetypes.inc                   |    3 +-
 core/includes/filetransfer/filetransfer.inc        |    6 +-
 core/includes/filetransfer/ftp.inc                 |    9 +-
 core/includes/filetransfer/local.inc               |    2 +
 core/includes/filetransfer/ssh.inc                 |    2 +
 core/includes/form.inc                             |  381 ++++----
 core/includes/gettext.inc                          |   17 +-
 core/includes/graph.inc                            |   13 +-
 core/includes/image.inc                            |    6 +-
 core/includes/install.core.inc                     |  232 +++---
 core/includes/install.inc                          |  149 ++--
 core/includes/language.inc                         |   33 +-
 core/includes/locale.inc                           |   23 +-
 core/includes/lock.inc                             |    4 +-
 core/includes/mail.inc                             |   93 +-
 core/includes/menu.inc                             |   88 +-
 core/includes/module.inc                           |  131 ++--
 core/includes/pager.inc                            |    5 +-
 core/includes/password.inc                         |   35 +-
 core/includes/path.inc                             |   86 +-
 core/includes/registry.inc                         |   10 +-
 core/includes/session.inc                          |  102 +-
 core/includes/standard.inc                         |    1 +
 core/includes/stream_wrappers.inc                  |   25 +-
 core/includes/tablesort.inc                        |    3 +-
 core/includes/theme.inc                            |  239 +++---
 core/includes/theme.maintenance.inc                |   41 +-
 core/includes/token.inc                            |    7 +-
 core/includes/unicode.entities.inc                 |    1 +
 core/includes/unicode.inc                          |   19 +-
 core/includes/update.inc                           |   80 +-
 core/includes/updater.inc                          |   17 +-
 core/includes/utility.inc                          |    2 +
 core/includes/uuid.inc                             |    5 +-
 core/includes/xmlrpc.inc                           |   10 +-
 core/includes/xmlrpcs.inc                          |   10 +-
 core/install.php                                   |    7 +-
 .../aggregator/aggregator-feed-source.tpl.php      |    1 +
 core/modules/aggregator/aggregator-item.tpl.php    |    1 +
 .../aggregator/aggregator-summary-item.tpl.php     |    1 +
 .../aggregator/aggregator-summary-items.tpl.php    |    1 +
 core/modules/aggregator/aggregator-wrapper.tpl.php |    1 +
 core/modules/aggregator/aggregator.admin.inc       |   38 +-
 core/modules/aggregator/aggregator.api.php         |    1 +
 core/modules/aggregator/aggregator.fetcher.inc     |    5 +-
 core/modules/aggregator/aggregator.install         |    1 +
 core/modules/aggregator/aggregator.module          |   41 +-
 core/modules/aggregator/aggregator.pages.inc       |   15 +-
 core/modules/aggregator/aggregator.parser.inc      |    7 +-
 core/modules/aggregator/aggregator.processor.inc   |   11 +-
 core/modules/aggregator/aggregator.test            |    7 +-
 .../aggregator/tests/aggregator_test.module        |   17 +-
 .../modules/block/block-admin-display-form.tpl.php |    9 +-
 core/modules/block/block.admin.inc                 |   32 +-
 core/modules/block/block.api.php                   |   19 +-
 core/modules/block/block.install                   |    3 +-
 core/modules/block/block.module                    |   48 +-
 core/modules/block/block.test                      |   52 +-
 core/modules/block/block.tpl.php                   |    1 +
 core/modules/block/tests/block_test.module         |    5 +-
 .../tests/themes/block_test_theme/page.tpl.php     |    1 +
 core/modules/book/book-all-books-block.tpl.php     |    1 +
 core/modules/book/book-export-html.tpl.php         |    1 +
 core/modules/book/book-navigation.tpl.php          |    1 +
 core/modules/book/book-node-export-html.tpl.php    |    1 +
 core/modules/book/book.admin.inc                   |   13 +-
 core/modules/book/book.install                     |    1 +
 core/modules/book/book.module                      |   32 +-
 core/modules/book/book.pages.inc                   |   25 +-
 core/modules/book/book.test                        |    3 +-
 core/modules/color/color.install                   |    1 +
 core/modules/color/color.module                    |   43 +-
 core/modules/color/color.test                      |    3 +-
 core/modules/comment/comment-wrapper.tpl.php       |    1 +
 core/modules/comment/comment.admin.inc             |   19 +-
 core/modules/comment/comment.api.php               |    7 +-
 core/modules/comment/comment.entity.inc            |    1 +
 core/modules/comment/comment.install               |    1 +
 core/modules/comment/comment.module                |   57 +-
 core/modules/comment/comment.pages.inc             |   37 +-
 core/modules/comment/comment.test                  |   67 +-
 core/modules/comment/comment.tokens.inc            |    1 +
 core/modules/comment/comment.tpl.php               |    1 +
 core/modules/contact/contact.admin.inc             |    9 +-
 core/modules/contact/contact.install               |    1 +
 core/modules/contact/contact.module                |   11 +-
 core/modules/contact/contact.pages.inc             |   29 +-
 core/modules/contact/contact.test                  |   21 +-
 core/modules/contextual/contextual.api.php         |    1 +
 core/modules/contextual/contextual.module          |    9 +-
 core/modules/dashboard/dashboard.api.php           |    1 +
 core/modules/dashboard/dashboard.install           |    3 +-
 core/modules/dashboard/dashboard.module            |   26 +-
 core/modules/dashboard/dashboard.test              |    3 +-
 core/modules/dblog/dblog.admin.inc                 |    9 +-
 core/modules/dblog/dblog.install                   |    1 +
 core/modules/dblog/dblog.module                    |    5 +-
 core/modules/dblog/dblog.test                      |    4 +-
 core/modules/entity/entity.api.php                 |   13 +-
 core/modules/entity/entity.class.inc               |   25 +-
 core/modules/entity/entity.controller.inc          |   43 +-
 core/modules/entity/entity.module                  |   45 +-
 core/modules/entity/entity.query.inc               |   13 +-
 core/modules/entity/tests/entity.test              |    9 +-
 core/modules/entity/tests/entity_cache_test.module |    1 +
 .../tests/entity_cache_test_dependency.module      |    1 +
 .../entity/tests/entity_crud_hook_test.module      |    1 +
 .../entity/tests/entity_crud_hook_test.test        |  171 ++--
 core/modules/entity/tests/entity_query.test        |   22 +-
 core/modules/entity/tests/entity_test.install      |    1 +
 core/modules/entity/tests/entity_test.module       |    1 +
 core/modules/field/field.api.php                   |   12 +-
 core/modules/field/field.attach.inc                |   26 +-
 core/modules/field/field.crud.inc                  |   14 +-
 core/modules/field/field.default.inc               |    7 +-
 core/modules/field/field.form.inc                  |   37 +-
 core/modules/field/field.info.inc                  |   37 +-
 core/modules/field/field.install                   |    6 +-
 core/modules/field/field.module                    |   40 +-
 core/modules/field/field.multilingual.inc          |   13 +-
 .../field_sql_storage/field_sql_storage.install    |    3 +-
 .../field_sql_storage/field_sql_storage.module     |   16 +-
 .../field_sql_storage/field_sql_storage.test       |    6 +-
 core/modules/field/modules/list/list.install       |    1 +
 core/modules/field/modules/list/list.module        |   12 +-
 core/modules/field/modules/list/tests/list.test    |   10 +-
 .../field/modules/list/tests/list_test.module      |    1 +
 core/modules/field/modules/number/number.install   |    1 +
 core/modules/field/modules/number/number.module    |   11 +-
 core/modules/field/modules/number/number.test      |    3 +-
 core/modules/field/modules/options/options.api.php |    1 +
 core/modules/field/modules/options/options.module  |    1 +
 core/modules/field/modules/options/options.test    |    1 +
 core/modules/field/modules/text/text.install       |    1 +
 core/modules/field/modules/text/text.module        |    3 +-
 core/modules/field/modules/text/text.test          |    8 +-
 core/modules/field/tests/field.test                |   26 +-
 core/modules/field/tests/field_test.entity.inc     |   34 +-
 core/modules/field/tests/field_test.field.inc      |    2 +
 core/modules/field/tests/field_test.install        |    1 +
 core/modules/field/tests/field_test.module         |   16 +-
 core/modules/field/tests/field_test.storage.inc    |    4 +-
 core/modules/field/theme/field.tpl.php             |    1 +
 core/modules/field_ui/field_ui.admin.inc           |   80 +-
 core/modules/field_ui/field_ui.api.php             |    1 +
 core/modules/field_ui/field_ui.module              |   19 +-
 core/modules/field_ui/field_ui.test                |    9 +-
 core/modules/file/file.api.php                     |    1 +
 core/modules/file/file.field.inc                   |   21 +-
 core/modules/file/file.install                     |    1 +
 core/modules/file/file.module                      |   27 +-
 core/modules/file/tests/file.test                  |    5 +-
 core/modules/file/tests/file_module_test.module    |    5 +-
 core/modules/filter/filter.admin.inc               |   36 +-
 core/modules/filter/filter.api.php                 |    1 +
 core/modules/filter/filter.install                 |    3 +-
 core/modules/filter/filter.module                  |   43 +-
 core/modules/filter/filter.pages.inc               |    3 +-
 core/modules/filter/filter.test                    |   28 +-
 core/modules/forum/forum-icon.tpl.php              |    1 +
 core/modules/forum/forum-list.tpl.php              |    1 +
 core/modules/forum/forum-submitted.tpl.php         |    1 +
 core/modules/forum/forum-topic-list.tpl.php        |    1 +
 core/modules/forum/forum.admin.inc                 |   19 +-
 core/modules/forum/forum.install                   |    3 +-
 core/modules/forum/forum.module                    |   26 +-
 core/modules/forum/forum.pages.inc                 |    1 +
 core/modules/forum/forum.test                      |    5 +-
 core/modules/forum/forums.tpl.php                  |    1 +
 core/modules/help/help.admin.inc                   |    9 +-
 core/modules/help/help.api.php                     |    1 +
 core/modules/help/help.module                      |    1 +
 core/modules/help/help.test                        |    9 +-
 core/modules/image/image.admin.inc                 |   37 +-
 core/modules/image/image.api.php                   |    1 +
 core/modules/image/image.effects.inc               |    1 +
 core/modules/image/image.field.inc                 |    5 +-
 core/modules/image/image.install                   |    1 +
 core/modules/image/image.module                    |   59 +-
 core/modules/image/image.test                      |   29 +-
 core/modules/image/tests/image_module_test.module  |    1 +
 core/modules/language/language.admin.inc           |   26 +-
 core/modules/language/language.api.php             |    1 +
 core/modules/language/language.install             |    3 +-
 core/modules/language/language.module              |   21 +-
 core/modules/language/language.test                |    7 +-
 core/modules/locale/locale.admin.inc               |   19 +-
 core/modules/locale/locale.api.php                 |    3 +-
 core/modules/locale/locale.bulk.inc                |   27 +-
 core/modules/locale/locale.install                 |    5 +-
 core/modules/locale/locale.module                  |   68 +-
 core/modules/locale/locale.pages.inc               |   25 +-
 core/modules/locale/locale.test                    |  108 ++-
 core/modules/locale/tests/locale_test.module       |    5 +-
 core/modules/menu/menu.admin.inc                   |   40 +-
 core/modules/menu/menu.api.php                     |    1 +
 core/modules/menu/menu.install                     |    1 +
 core/modules/menu/menu.module                      |   28 +-
 core/modules/menu/menu.test                        |    5 +-
 core/modules/node/content_types.inc                |   22 +-
 core/modules/node/node.admin.inc                   |   21 +-
 core/modules/node/node.api.php                     |   11 +-
 core/modules/node/node.install                     |    2 +
 core/modules/node/node.module                      |  102 +-
 core/modules/node/node.pages.inc                   |   51 +-
 core/modules/node/node.test                        |   72 +-
 core/modules/node/node.tokens.inc                  |    1 +
 core/modules/node/node.tpl.php                     |    1 +
 core/modules/node/tests/node_access_test.install   |    1 +
 core/modules/node/tests/node_access_test.module    |    2 +
 core/modules/node/tests/node_test.module           |    1 +
 core/modules/node/tests/node_test_exception.module |    2 +
 core/modules/openid/openid.api.php                 |    1 +
 core/modules/openid/openid.inc                     |    9 +-
 core/modules/openid/openid.install                 |    1 +
 core/modules/openid/openid.module                  |   48 +-
 core/modules/openid/openid.pages.inc               |   17 +-
 core/modules/openid/openid.test                    |   10 +-
 core/modules/openid/tests/openid_test.install      |    1 +
 core/modules/openid/tests/openid_test.module       |   30 +-
 core/modules/overlay/overlay.api.php               |    5 +-
 core/modules/overlay/overlay.install               |    1 +
 core/modules/overlay/overlay.module                |   77 +-
 core/modules/overlay/overlay.tpl.php               |    1 +
 core/modules/path/path.admin.inc                   |   22 +-
 core/modules/path/path.api.php                     |    1 +
 core/modules/path/path.module                      |    5 +-
 core/modules/path/path.test                        |   37 +-
 core/modules/php/php.install                       |    5 +-
 core/modules/php/php.module                        |    3 +-
 core/modules/php/php.test                          |    3 +-
 core/modules/poll/poll-bar--block.tpl.php          |    1 +
 core/modules/poll/poll-bar.tpl.php                 |    1 +
 core/modules/poll/poll-results--block.tpl.php      |    1 +
 core/modules/poll/poll-results.tpl.php             |    1 +
 core/modules/poll/poll-vote.tpl.php                |    1 +
 core/modules/poll/poll.install                     |    1 +
 core/modules/poll/poll.module                      |   22 +-
 core/modules/poll/poll.pages.inc                   |    5 +-
 core/modules/poll/poll.test                        |   13 +-
 core/modules/poll/poll.tokens.inc                  |    1 +
 core/modules/rdf/rdf.api.php                       |    1 +
 core/modules/rdf/rdf.install                       |    1 +
 core/modules/rdf/rdf.module                        |   25 +-
 core/modules/rdf/rdf.test                          |   19 +-
 core/modules/rdf/tests/rdf_test.install            |    1 +
 core/modules/rdf/tests/rdf_test.module             |    1 +
 core/modules/search/search-result.tpl.php          |    1 +
 core/modules/search/search-results.tpl.php         |    3 +-
 core/modules/search/search.admin.inc               |    9 +-
 core/modules/search/search.api.php                 |    3 +-
 core/modules/search/search.extender.inc            |    5 +-
 core/modules/search/search.install                 |    1 +
 core/modules/search/search.module                  |   31 +-
 core/modules/search/search.pages.inc               |    7 +-
 core/modules/search/search.test                    |   73 +-
 .../search/tests/search_embedded_form.module       |    7 +-
 core/modules/search/tests/search_extra_type.module |    1 +
 core/modules/shortcut/shortcut.admin.inc           |   55 +-
 core/modules/shortcut/shortcut.api.php             |    1 +
 core/modules/shortcut/shortcut.install             |    6 +-
 core/modules/shortcut/shortcut.module              |   41 +-
 core/modules/shortcut/shortcut.test                |    6 +-
 core/modules/simpletest/drupal_web_test_case.php   |  106 ++-
 core/modules/simpletest/simpletest.api.php         |    5 +-
 core/modules/simpletest/simpletest.install         |    4 +-
 core/modules/simpletest/simpletest.module          |   48 +-
 core/modules/simpletest/simpletest.pages.inc       |   28 +-
 core/modules/simpletest/simpletest.test            |   56 +-
 core/modules/simpletest/tests/actions.test         |   11 +-
 .../simpletest/tests/actions_loop_test.install     |    1 +
 .../simpletest/tests/actions_loop_test.module      |    1 +
 core/modules/simpletest/tests/ajax.test            |   15 +-
 .../simpletest/tests/ajax_forms_test.module        |   21 +-
 core/modules/simpletest/tests/ajax_test.module     |    5 +-
 core/modules/simpletest/tests/batch.test           |   13 +-
 .../simpletest/tests/batch_test.callbacks.inc      |    3 +-
 core/modules/simpletest/tests/batch_test.module    |   37 +-
 core/modules/simpletest/tests/bootstrap.test       |   79 +-
 core/modules/simpletest/tests/cache.test           |    8 +-
 core/modules/simpletest/tests/common.test          |  664 +++++++-------
 core/modules/simpletest/tests/common_test.module   |   92 +-
 .../tests/common_test_cron_helper.module           |    2 +
 .../modules/simpletest/tests/database_test.install |    1 +
 core/modules/simpletest/tests/database_test.module |   13 +-
 core/modules/simpletest/tests/database_test.test   |   30 +-
 .../drupal_system_listing_compatible_test.module   |    1 +
 .../drupal_system_listing_incompatible_test.module |    1 +
 core/modules/simpletest/tests/error.test           |   14 +-
 core/modules/simpletest/tests/error_test.module    |    2 +
 core/modules/simpletest/tests/file.test            |   64 +-
 core/modules/simpletest/tests/file_test.module     |   21 +-
 core/modules/simpletest/tests/filetransfer.test    |    8 +-
 core/modules/simpletest/tests/filter_test.module   |    7 +-
 core/modules/simpletest/tests/form.test            |   53 +-
 core/modules/simpletest/tests/form_test.file.inc   |    5 +-
 core/modules/simpletest/tests/form_test.module     |  111 ++--
 core/modules/simpletest/tests/graph.test           |   15 +-
 core/modules/simpletest/tests/http.php             |   11 +-
 core/modules/simpletest/tests/https.php            |   11 +-
 core/modules/simpletest/tests/image.test           |   12 +-
 core/modules/simpletest/tests/image_test.module    |    2 +
 core/modules/simpletest/tests/installer.test       |    7 +-
 core/modules/simpletest/tests/lock.test            |    3 +-
 core/modules/simpletest/tests/mail.test            |   37 +-
 core/modules/simpletest/tests/menu.test            |   28 +-
 core/modules/simpletest/tests/menu_test.module     |    3 +-
 core/modules/simpletest/tests/module.test          |   53 +-
 core/modules/simpletest/tests/module_test.file.inc |    1 +
 core/modules/simpletest/tests/module_test.install  |    5 +-
 core/modules/simpletest/tests/module_test.module   |    1 +
 core/modules/simpletest/tests/password.test        |   11 +-
 core/modules/simpletest/tests/path.test            |   49 +-
 core/modules/simpletest/tests/registry.test        |    6 +-
 .../simpletest/tests/requirements1_test.install    |    1 +
 .../simpletest/tests/requirements1_test.module     |    1 +
 .../simpletest/tests/requirements2_test.module     |    1 +
 core/modules/simpletest/tests/schema.test          |    4 +-
 core/modules/simpletest/tests/session.test         |   27 +-
 core/modules/simpletest/tests/session_test.module  |   17 +-
 core/modules/simpletest/tests/symfony.test         |    3 +-
 .../tests/system_dependencies_test.module          |    1 +
 ...ompatible_core_version_dependencies_test.module |    1 +
 .../system_incompatible_core_version_test.module   |    1 +
 ...patible_module_version_dependencies_test.module |    1 +
 .../system_incompatible_module_version_test.module |    1 +
 core/modules/simpletest/tests/system_test.module   |   40 +-
 core/modules/simpletest/tests/tablesort.test       |    3 +-
 .../modules/simpletest/tests/taxonomy_test.install |    1 +
 core/modules/simpletest/tests/taxonomy_test.module |    1 +
 core/modules/simpletest/tests/theme.test           |   32 +-
 core/modules/simpletest/tests/theme_test.module    |    9 +-
 .../tests/themes/test_theme/template.php           |    3 +-
 core/modules/simpletest/tests/unicode.test         |    3 +-
 core/modules/simpletest/tests/update.test          |   13 +-
 .../simpletest/tests/update_script_test.install    |    1 +
 .../simpletest/tests/update_script_test.module     |    3 +-
 .../modules/simpletest/tests/update_test_1.install |    1 +
 core/modules/simpletest/tests/update_test_1.module |    1 +
 .../modules/simpletest/tests/update_test_2.install |    1 +
 core/modules/simpletest/tests/update_test_2.module |    1 +
 .../modules/simpletest/tests/update_test_3.install |    1 +
 core/modules/simpletest/tests/update_test_3.module |    1 +
 core/modules/simpletest/tests/upgrade/upgrade.test |   32 +-
 .../simpletest/tests/upgrade/upgrade_bare.test     |    3 +-
 .../simpletest/tests/upgrade/upgrade_filled.test   |    3 +-
 .../simpletest/tests/url_alter_test.install        |    1 +
 .../modules/simpletest/tests/url_alter_test.module |    3 +-
 core/modules/simpletest/tests/xmlrpc.test          |    7 +-
 core/modules/simpletest/tests/xmlrpc_test.module   |    1 +
 core/modules/statistics/statistics.admin.inc       |   15 +-
 core/modules/statistics/statistics.install         |    1 +
 core/modules/statistics/statistics.module          |   17 +-
 core/modules/statistics/statistics.pages.inc       |    9 +-
 core/modules/statistics/statistics.test            |   12 +-
 core/modules/statistics/statistics.tokens.inc      |    1 +
 core/modules/syslog/syslog.install                 |    1 +
 core/modules/syslog/syslog.module                  |    1 +
 core/modules/syslog/syslog.test                    |    3 +-
 core/modules/system/html.tpl.php                   |    1 +
 core/modules/system/image.gd.inc                   |    2 +
 core/modules/system/maintenance-page.tpl.php       |    1 +
 core/modules/system/page.tpl.php                   |    1 +
 core/modules/system/region.tpl.php                 |    1 +
 core/modules/system/system.admin.inc               |  262 +++---
 core/modules/system/system.api.php                 |  188 ++--
 core/modules/system/system.archiver.inc            |    2 +
 core/modules/system/system.install                 |   50 +-
 core/modules/system/system.mail.inc                |    7 +-
 core/modules/system/system.module                  |  248 +++---
 core/modules/system/system.queue.inc               |   43 +-
 core/modules/system/system.tar.inc                 |    2 +
 core/modules/system/system.test                    |  106 ++-
 core/modules/system/system.tokens.inc              |    1 +
 core/modules/system/system.updater.inc             |   35 +-
 core/modules/system/theme.api.php                  |    1 +
 core/modules/taxonomy/taxonomy-term.tpl.php        |    1 +
 core/modules/taxonomy/taxonomy.admin.inc           |   41 +-
 core/modules/taxonomy/taxonomy.api.php             |    1 +
 core/modules/taxonomy/taxonomy.install             |    1 +
 core/modules/taxonomy/taxonomy.module              |   56 +-
 core/modules/taxonomy/taxonomy.pages.inc           |   13 +-
 core/modules/taxonomy/taxonomy.test                |   30 +-
 core/modules/taxonomy/taxonomy.tokens.inc          |    1 +
 core/modules/toolbar/toolbar.module                |    9 +-
 core/modules/toolbar/toolbar.tpl.php               |    1 +
 core/modules/tracker/tracker.install               |    1 +
 core/modules/tracker/tracker.module                |    1 +
 core/modules/tracker/tracker.pages.inc             |    5 +-
 core/modules/tracker/tracker.test                  |    3 +-
 .../translation/tests/translation_test.module      |    3 +-
 core/modules/translation/translation.module        |    3 +-
 core/modules/translation/translation.pages.inc     |    5 +-
 core/modules/translation/translation.test          |   11 +-
 core/modules/update/tests/aaa_update_test.module   |    1 +
 core/modules/update/tests/bbb_update_test.module   |    1 +
 core/modules/update/tests/ccc_update_test.module   |    1 +
 core/modules/update/tests/update_test.module       |    9 +-
 core/modules/update/update.api.php                 |    1 +
 core/modules/update/update.authorize.inc           |    6 +-
 core/modules/update/update.compare.inc             |    9 +-
 core/modules/update/update.fetch.inc               |   24 +-
 core/modules/update/update.install                 |    9 +-
 core/modules/update/update.manager.inc             |   36 +-
 core/modules/update/update.module                  |   37 +-
 core/modules/update/update.report.inc              |    7 +-
 core/modules/update/update.settings.inc            |    1 +
 core/modules/update/update.test                    |    8 +-
 core/modules/user/tests/user_form_test.module      |    5 +-
 core/modules/user/user-picture.tpl.php             |    1 +
 core/modules/user/user-profile.tpl.php             |    1 +
 core/modules/user/user.admin.inc                   |   51 +-
 core/modules/user/user.api.php                     |    5 +-
 core/modules/user/user.entity.inc                  |    9 +-
 core/modules/user/user.install                     |    9 +-
 core/modules/user/user.module                      |  184 ++--
 core/modules/user/user.pages.inc                   |   47 +-
 core/modules/user/user.test                        |   79 +-
 core/modules/user/user.tokens.inc                  |    1 +
 core/scripts/dump-database-d7.sh                   |    6 +-
 core/scripts/generate-d7-content.sh                |   14 +-
 core/scripts/password-hash.sh                      |    7 +-
 core/scripts/run-tests.sh                          |   12 +-
 core/themes/bartik/color/color.inc                 |    3 +-
 core/themes/bartik/template.php                    |    5 +-
 .../bartik/templates/comment-wrapper.tpl.php       |    1 +
 core/themes/bartik/templates/comment.tpl.php       |    1 +
 .../bartik/templates/maintenance-page.tpl.php      |    1 +
 core/themes/bartik/templates/node.tpl.php          |    1 +
 core/themes/bartik/templates/page.tpl.php          |    1 +
 core/themes/engines/phptemplate/phptemplate.engine |    7 +-
 core/themes/seven/maintenance-page.tpl.php         |    3 +
 core/themes/seven/page.tpl.php                     |    3 +
 core/themes/seven/template.php                     |   11 +-
 core/update.php                                    |   92 +-
 core/xmlrpc.php                                    |   11 +-
 index.php                                          |    7 +-
 profiles/minimal/minimal.install                   |    5 +-
 profiles/standard/standard.install                 |    6 +-
 .../drupal_system_listing_compatible_test.module   |    1 +
 .../drupal_system_listing_incompatible_test.module |    1 +
 profiles/testing/testing.install                   |    1 +
 sites/default/default.settings.php                 |    9 +-
 sites/example.sites.php                            |    1 +
 482 files changed, 5924 insertions(+), 5249 deletions(-)

diff --git a/core/authorize.php b/core/authorize.php
index c6ba51d..37343f9 100644
--- a/core/authorize.php
+++ b/core/authorize.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -26,7 +27,7 @@ chdir('..');
 /**
  * Root directory of Drupal installation.
  */
-define('DRUPAL_ROOT', getcwd());
+define('ROOT', getcwd());
 
 /**
  * Global flag to identify update.php and authorize.php runs, and so
@@ -35,15 +36,15 @@ define('DRUPAL_ROOT', getcwd());
  * solve some theming issues. This flag is checked on several places
  * in Drupal code (not just authorize.php).
  */
-const MAINTENANCE_MODE = 'update';
+define('MAINTENANCE_MODE', 'update');
 
 /**
  * Renders a 403 access denied page for authorize.php.
  */
 function authorize_access_denied_page() {
-  drupal_add_http_header('Status', '403 Forbidden');
+  add_http_header('Status', '403 Forbidden');
   watchdog('access denied', 'authorize.php', NULL, WATCHDOG_WARNING);
-  drupal_set_title('Access denied');
+  set_title('Access denied');
   return t('You are not allowed to access this page.');
 }
 
@@ -62,18 +63,18 @@ function authorize_access_allowed() {
 
 // *** Real work of the script begins here. ***
 
-require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
-require_once DRUPAL_ROOT . '/core/includes/session.inc';
-require_once DRUPAL_ROOT . '/core/includes/common.inc';
-require_once DRUPAL_ROOT . '/core/includes/file.inc';
-require_once DRUPAL_ROOT . '/core/includes/module.inc';
-require_once DRUPAL_ROOT . '/core/includes/ajax.inc';
+require_once ROOT . '/core/includes/bootstrap.inc';
+require_once ROOT . '/core/includes/session.inc';
+require_once ROOT . '/core/includes/common.inc';
+require_once ROOT . '/core/includes/file.inc';
+require_once ROOT . '/core/includes/module.inc';
+require_once ROOT . '/core/includes/ajax.inc';
 
 // We prepare only a minimal bootstrap. This includes the database and
 // variables, however, so we have access to the class autoloader registry.
-drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
+bootstrap(BOOTSTRAP_SESSION);
 
-// This must go after drupal_bootstrap(), which unsets globals!
+// This must go after bootstrap(), which unsets globals!
 global $conf;
 
 // We have to enable the user and system modules, even to check access and
@@ -81,27 +82,27 @@ global $conf;
 $module_list['system']['filename'] = 'core/modules/system/system.module';
 $module_list['user']['filename'] = 'core/modules/user/user.module';
 module_list(TRUE, FALSE, FALSE, $module_list);
-drupal_load('module', 'system');
-drupal_load('module', 'user');
+load('module', 'system');
+load('module', 'user');
 
 // We also want to have the language system available, but we do *NOT* want to
-// actually call drupal_bootstrap(DRUPAL_BOOTSTRAP_LANGUAGE), since that would
-// also force us through the DRUPAL_BOOTSTRAP_PAGE_HEADER phase, which loads
+// actually call bootstrap(BOOTSTRAP_LANGUAGE), since that would
+// also force us through the BOOTSTRAP_PAGE_HEADER phase, which loads
 // all the modules, and that's exactly what we're trying to avoid.
-drupal_language_initialize();
+language_initialize();
 
 // Initialize the maintenance theme for this administrative script.
-drupal_maintenance_theme();
+maintenance_theme();
 
 $output = '';
 $show_messages = TRUE;
 
 if (authorize_access_allowed()) {
   // Load both the Form API and Batch API.
-  require_once DRUPAL_ROOT . '/core/includes/form.inc';
-  require_once DRUPAL_ROOT . '/core/includes/batch.inc';
+  require_once ROOT . '/core/includes/form.inc';
+  require_once ROOT . '/core/includes/batch.inc';
   // Load the code that drives the authorize process.
-  require_once DRUPAL_ROOT . '/core/includes/authorize.inc';
+  require_once ROOT . '/core/includes/authorize.inc';
 
   // For the sake of Batch API and a few other low-level functions, we need to
   // initialize the URL path into $_GET['q']. However, we do not want to raise
@@ -115,10 +116,10 @@ if (authorize_access_allowed()) {
   }
 
   if (isset($_SESSION['authorize_operation']['page_title'])) {
-    drupal_set_title($_SESSION['authorize_operation']['page_title']);
+    set_title($_SESSION['authorize_operation']['page_title']);
   }
   else {
-    drupal_set_title(t('Authorize file system changes'));
+    set_title(t('Authorize file system changes'));
   }
 
   // See if we've run the operation and need to display a report.
@@ -130,10 +131,10 @@ if (authorize_access_allowed()) {
     unset($_SESSION['authorize_filetransfer_info']);
 
     if (!empty($results['page_title'])) {
-      drupal_set_title($results['page_title']);
+      set_title($results['page_title']);
     }
     if (!empty($results['page_message'])) {
-      drupal_set_message($results['page_message']['message'], $results['page_message']['type']);
+      set_message($results['page_message']['message'], $results['page_message']['type']);
     }
 
     $output = theme('authorize_report', array('messages' => $results['messages']));
@@ -161,7 +162,7 @@ if (authorize_access_allowed()) {
     }
     elseif (!$batch = batch_get()) {
       // We have a batch to process, show the filetransfer form.
-      $elements = drupal_get_form('authorize_filetransfer_form');
+      $elements = get_form('authorize_filetransfer_form');
       $output = drupal_render($elements);
     }
   }
diff --git a/core/cron.php b/core/cron.php
index fa9aa14..68d1402 100644
--- a/core/cron.php
+++ b/core/cron.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -11,19 +12,19 @@ chdir('..');
 /**
  * Root directory of Drupal installation.
  */
-define('DRUPAL_ROOT', getcwd());
+define('ROOT', getcwd());
 
-include_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
-drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+include_once ROOT . '/core/includes/bootstrap.inc';
+bootstrap(BOOTSTRAP_FULL);
 
 if (!isset($_GET['cron_key']) || variable_get('cron_key', 'drupal') != $_GET['cron_key']) {
   watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE);
-  drupal_access_denied();
+  access_denied();
 }
 elseif (variable_get('maintenance_mode', 0)) {
   watchdog('cron', 'Cron could not run because the site is in maintenance mode.', array(), WATCHDOG_NOTICE);
-  drupal_access_denied();
+  access_denied();
 }
 else {
-  drupal_cron_run();
+  cron_run();
 }
diff --git a/core/includes/Drupal/Cache/CacheBackendInterface.php b/core/includes/Drupal/Cache/CacheBackendInterface.php
index 3cb3c46..7bcab5b 100644
--- a/core/includes/Drupal/Cache/CacheBackendInterface.php
+++ b/core/includes/Drupal/Cache/CacheBackendInterface.php
@@ -7,6 +7,8 @@
 
 namespace Drupal\Cache;
 
+use Drupal;
+
 /**
  * Defines an interface for cache implementations.
  *
@@ -92,14 +94,14 @@ interface CacheBackendInterface {
    *   Strings will be stored as plain text and not serialized.
    * @param $expire
    *   One of the following values:
-   *   - CACHE_PERMANENT: Indicates that the item should never be removed unless
-   *     explicitly told to using cache_clear_all() with a cache ID.
-   *   - CACHE_TEMPORARY: Indicates that the item should be removed at the next
-   *     general cache wipe.
+   *   - Drupal\CACHE_PERMANENT: Indicates that the item should never be removed
+   *     unless explicitly told to using cache_clear_all() with a cache ID.
+   *   - Drupal\CACHE_TEMPORARY: Indicates that the item should be removed at
+   *     the next general cache wipe.
    *   - A Unix timestamp: Indicates that the item should be kept at least until
-   *     the given time, after which it behaves like CACHE_TEMPORARY.
+   *     the given time, after which it behaves like Drupal\CACHE_TEMPORARY.
    */
-  function set($cid, $data, $expire = CACHE_PERMANENT);
+  function set($cid, $data, $expire = Drupal\CACHE_PERMANENT);
 
   /**
    * Deletes an item from the cache.
diff --git a/core/includes/Drupal/Cache/DatabaseBackend.php b/core/includes/Drupal/Cache/DatabaseBackend.php
index 5d9be14..2a1a532 100644
--- a/core/includes/Drupal/Cache/DatabaseBackend.php
+++ b/core/includes/Drupal/Cache/DatabaseBackend.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Cache;
 
+use Drupal;
 use Exception;
 
 /**
@@ -58,7 +59,7 @@ class DatabaseBackend implements CacheBackendInterface {
       // is used here only due to the performance overhead we would incur
       // otherwise. When serving an uncached page, the overhead of using
       // db_select() is a much smaller proportion of the request.
-      $result = db_query('SELECT cid, data, created, expire, serialized FROM {' . db_escape_table($this->bin) . '} WHERE cid IN (:cids)', array(':cids' => $cids));
+      $result = Drupal\db_query('SELECT cid, data, created, expire, serialized FROM {' . Drupal\db_escape_table($this->bin) . '} WHERE cid IN (:cids)', array(':cids' => $cids));
       $cache = array();
       foreach ($result as $item) {
         $item = $this->prepareItem($item);
@@ -101,7 +102,7 @@ class DatabaseBackend implements CacheBackendInterface {
     // timer. The cache variable is loaded into the $user object by
     // _drupal_session_read() in session.inc. If the data is permanent or we're
     // not enforcing a minimum cache lifetime always return the cached data.
-    if ($cache->expire != CACHE_PERMANENT && variable_get('cache_lifetime', 0) && $user->cache > $cache->created) {
+    if ($cache->expire != Drupal\CACHE_PERMANENT && Drupal\variable_get('cache_lifetime', 0) && $user->cache > $cache->created) {
       // This cache data is too old and thus not valid for us, ignore it.
       return FALSE;
     }
@@ -116,7 +117,7 @@ class DatabaseBackend implements CacheBackendInterface {
   /**
    * Implements Drupal\Cache\CacheBackendInterface::set().
    */
-  function set($cid, $data, $expire = CACHE_PERMANENT) {
+  function set($cid, $data, $expire = Drupal\CACHE_PERMANENT) {
     $fields = array(
       'serialized' => 0,
       'created' => REQUEST_TIME,
@@ -132,7 +133,7 @@ class DatabaseBackend implements CacheBackendInterface {
     }
 
     try {
-      db_merge($this->bin)
+      Drupal\db_merge($this->bin)
         ->key(array('cid' => $cid))
         ->fields($fields)
         ->execute();
@@ -146,7 +147,7 @@ class DatabaseBackend implements CacheBackendInterface {
    * Implements Drupal\Cache\CacheBackendInterface::delete().
    */
   function delete($cid) {
-    db_delete($this->bin)
+    Drupal\db_delete($this->bin)
       ->condition('cid', $cid)
       ->execute();
   }
@@ -157,7 +158,7 @@ class DatabaseBackend implements CacheBackendInterface {
   function deleteMultiple(Array $cids) {
     // Delete in chunks when a large array is passed.
     do {
-      db_delete($this->bin)
+      Drupal\db_delete($this->bin)
         ->condition('cid', array_splice($cids, 0, 1000), 'IN')
         ->execute();
     }
@@ -168,8 +169,8 @@ class DatabaseBackend implements CacheBackendInterface {
    * Implements Drupal\Cache\CacheBackendInterface::deletePrefix().
    */
   function deletePrefix($prefix) {
-    db_delete($this->bin)
-      ->condition('cid', db_like($prefix) . '%', 'LIKE')
+    Drupal\db_delete($this->bin)
+      ->condition('cid', Drupal\db_like($prefix) . '%', 'LIKE')
       ->execute();
   }
 
@@ -177,39 +178,39 @@ class DatabaseBackend implements CacheBackendInterface {
    * Implements Drupal\Cache\CacheBackendInterface::flush().
    */
   function flush() {
-    db_truncate($this->bin)->execute();
+    Drupal\db_truncate($this->bin)->execute();
   }
 
   /**
    * Implements Drupal\Cache\CacheBackendInterface::expire().
    */
   function expire() {
-    if (variable_get('cache_lifetime', 0)) {
+    if (Drupal\variable_get('cache_lifetime', 0)) {
       // We store the time in the current user's $user->cache variable which
       // will be saved into the sessions bin by _drupal_session_write(). We then
       // simulate that the cache was flushed for this user by not returning
       // cached data that was cached before the timestamp.
       $GLOBALS['user']->cache = REQUEST_TIME;
 
-      $cache_flush = variable_get('cache_flush_' . $this->bin, 0);
+      $cache_flush = Drupal\variable_get('cache_flush_' . $this->bin, 0);
       if ($cache_flush == 0) {
         // This is the first request to clear the cache, start a timer.
-        variable_set('cache_flush_' . $this->bin, REQUEST_TIME);
+        Drupal\variable_set('cache_flush_' . $this->bin, REQUEST_TIME);
       }
-      elseif (REQUEST_TIME > ($cache_flush + variable_get('cache_lifetime', 0))) {
+      elseif (REQUEST_TIME > ($cache_flush + Drupal\variable_get('cache_lifetime', 0))) {
         // Clear the cache for everyone; cache_lifetime seconds have passed
         // since the first request to clear the cache.
-        db_delete($this->bin)
-          ->condition('expire', CACHE_PERMANENT, '<>')
+        Drupal\db_delete($this->bin)
+          ->condition('expire', Drupal\CACHE_PERMANENT, '<>')
           ->condition('expire', REQUEST_TIME, '<')
           ->execute();
-        variable_set('cache_flush_' . $this->bin, 0);
+        Drupal\variable_set('cache_flush_' . $this->bin, 0);
       }
     }
     else {
       // No minimum cache lifetime, flush all temporary cache entries now.
-      db_delete($this->bin)
-        ->condition('expire', CACHE_PERMANENT, '<>')
+      Drupal\db_delete($this->bin)
+        ->condition('expire', Drupal\CACHE_PERMANENT, '<>')
         ->condition('expire', REQUEST_TIME, '<')
         ->execute();
     }
@@ -223,13 +224,13 @@ class DatabaseBackend implements CacheBackendInterface {
 
     // When cache lifetime is in force, avoid running garbage collection too
     // often since this will remove temporary cache items indiscriminately.
-    $cache_flush = variable_get('cache_flush_' . $this->bin, 0);
-    if ($cache_flush && ($cache_flush + variable_get('cache_lifetime', 0) <= REQUEST_TIME)) {
+    $cache_flush = Drupal\variable_get('cache_flush_' . $this->bin, 0);
+    if ($cache_flush && ($cache_flush + Drupal\variable_get('cache_lifetime', 0) <= REQUEST_TIME)) {
       // Reset the variable immediately to prevent a meltdown in heavy load situations.
-      variable_set('cache_flush_' . $this->bin, 0);
+      Drupal\variable_set('cache_flush_' . $this->bin, 0);
       // Time to flush old cache data
-      db_delete($this->bin)
-        ->condition('expire', CACHE_PERMANENT, '<>')
+      Drupal\db_delete($this->bin)
+        ->condition('expire', Drupal\CACHE_PERMANENT, '<>')
         ->condition('expire', $cache_flush, '<=')
         ->execute();
     }
@@ -240,7 +241,7 @@ class DatabaseBackend implements CacheBackendInterface {
    */
   function isEmpty() {
     $this->garbageCollection();
-    $query = db_select($this->bin);
+    $query = Drupal\db_select($this->bin);
     $query->addExpression('1');
     $result = $query->range(0, 1)
       ->execute()
diff --git a/core/includes/Drupal/Cache/InstallBackend.php b/core/includes/Drupal/Cache/InstallBackend.php
index f13ff98..297267b 100644
--- a/core/includes/Drupal/Cache/InstallBackend.php
+++ b/core/includes/Drupal/Cache/InstallBackend.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Cache;
 
+use Drupal;
 use Exception;
 
 /**
@@ -50,7 +51,7 @@ class InstallBackend extends DatabaseBackend {
   /**
    * Overrides Drupal\Cache\DatabaseBackend::set().
    */
-  function set($cid, $data, $expire = CACHE_PERMANENT) {}
+  function set($cid, $data, $expire = Drupal\CACHE_PERMANENT) {}
 
   /**
    * Implements Drupal\Cache\DatabaseBackend::delete().
diff --git a/core/includes/Drupal/Cache/NullBackend.php b/core/includes/Drupal/Cache/NullBackend.php
index 3ab731c..4d52345 100644
--- a/core/includes/Drupal/Cache/NullBackend.php
+++ b/core/includes/Drupal/Cache/NullBackend.php
@@ -7,6 +7,8 @@
 
 namespace Drupal\Cache;
 
+use Drupal;
+
 /**
  * Defines a stub cache implementation.
  *
@@ -42,7 +44,7 @@ class NullBackend implements CacheBackendInterface {
   /**
    * Implements Drupal\Cache\CacheBackendInterface::set().
    */
-  function set($cid, $data, $expire = CACHE_PERMANENT) {}
+  function set($cid, $data, $expire = Drupal\CACHE_PERMANENT) {}
 
   /**
    * Implements Drupal\Cache\CacheBackendInterface::delete().
diff --git a/core/includes/actions.inc b/core/includes/actions.inc
index 75cda42..f18b114 100644
--- a/core/includes/actions.inc
+++ b/core/includes/actions.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use PDO;
 
 /**
  * @file
@@ -96,7 +98,7 @@ function actions_do($action_ids, $object = NULL, $context = NULL, $a1 = NULL, $a
     foreach ($actions as $action_id => $params) {
       // Configurable actions need parameters.
       if (is_numeric($action_id)) {
-        $function = $params['callback'];
+        $function = 'Drupal\\' . $params['callback'];
         if (function_exists($function)) {
           $context = array_merge($context, $params);
           $actions_result[$action_id] = $function($object, $context, $a1, $a2);
@@ -107,7 +109,7 @@ function actions_do($action_ids, $object = NULL, $context = NULL, $a1 = NULL, $a
       }
       // Singleton action; $action_id is the function name.
       else {
-        $actions_result[$action_id] = $action_id($object, $context, $a1, $a2);
+        $actions_result[$action_id] = call_user_func('Drupal\\' . $action_id, $object, $context, $a1, $a2);
       }
     }
   }
@@ -116,7 +118,7 @@ function actions_do($action_ids, $object = NULL, $context = NULL, $a1 = NULL, $a
     // If it's a configurable action, retrieve stored parameters.
     if (is_numeric($action_ids)) {
       $action = db_query("SELECT callback, parameters FROM {actions} WHERE aid = :aid", array(':aid' => $action_ids))->fetchObject();
-      $function = $action->callback;
+      $function = 'Drupal\\' . $action->callback;
       if (function_exists($function)) {
         $context = array_merge($context, unserialize($action->parameters));
         $actions_result[$action_ids] = $function($object, $context, $a1, $a2);
@@ -127,8 +129,9 @@ function actions_do($action_ids, $object = NULL, $context = NULL, $a1 = NULL, $a
     }
     // Singleton action; $action_ids is the function name.
     else {
-      if (function_exists($action_ids)) {
-        $actions_result[$action_ids] = $action_ids($object, $context, $a1, $a2);
+      $function = 'Drupal\\' . $action_ids;
+      if (function_exists($function)) {
+        $actions_result[$action_ids] = $function($object, $context, $a1, $a2);
       }
       else {
         // Set to avoid undefined index error messages later.
@@ -161,7 +164,7 @@ function actions_list($reset = FALSE) {
   $actions = &drupal_static(__FUNCTION__);
   if (!isset($actions) || $reset) {
     $actions = module_invoke_all('action_info');
-    drupal_alter('action_info', $actions);
+    alter('action_info', $actions);
   }
 
   // See module_implements() for an explanation of this cast.
@@ -214,7 +217,7 @@ function actions_get_all_actions() {
 function actions_actions_map($actions) {
   $actions_map = array();
   foreach ($actions as $callback => $array) {
-    $key = drupal_hash_base64($callback);
+    $key = hash_base64($callback);
     $actions_map[$key]['callback']     = isset($array['callback']) ? $array['callback'] : $callback;
     $actions_map[$key]['label']        = $array['label'];
     $actions_map[$key]['type']         = $array['type'];
@@ -240,7 +243,7 @@ function actions_function_lookup($hash) {
   // Check for a function name match.
   $actions_list = actions_list();
   foreach ($actions_list as $function => $array) {
-    if (drupal_hash_base64($function) == $hash) {
+    if (hash_base64($function) == $hash) {
       return $function;
     }
   }
@@ -248,7 +251,7 @@ function actions_function_lookup($hash) {
   // Must be a configurable action; check database.
   $result = db_query("SELECT aid FROM {actions} WHERE parameters <> ''")->fetchAll(PDO::FETCH_ASSOC);
   foreach ($result as $row) {
-    if (drupal_hash_base64($row['aid']) == $hash) {
+    if (hash_base64($row['aid']) == $hash) {
       $aid = $row['aid'];
       break;
     }
diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc
index 8683ff9..e023d2b 100644
--- a/core/includes/ajax.inc
+++ b/core/includes/ajax.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -37,7 +38,7 @@
  *   - The browser submits an HTTP POST request to the 'system/ajax' Drupal
  *     path.
  *   - The menu page callback for 'system/ajax', ajax_form_callback(), calls
- *     drupal_process_form() to process the form submission and rebuild the
+ *     process_form() to process the form submission and rebuild the
  *     form if necessary. The form is processed in much the same way as if it
  *     were submitted without Ajax, with the same #process functions and
  *     validation and submission handlers called in either case, making it easy
@@ -61,7 +62,7 @@
  * @link http://drupal.org/project/examples Examples module @endlink follows:
  * @code
  * function main_page() {
- *   return drupal_get_form('ajax_example_simplest');
+ *   return get_form('ajax_example_simplest');
  * }
  *
  * function ajax_example_simplest($form, &$form_state) {
@@ -231,7 +232,7 @@
  */
 function ajax_render($commands = array()) {
   // Ajax responses aren't rendered with html.tpl.php, so we have to call
-  // drupal_get_css() and drupal_get_js() here, in order to have new files added
+  // get_css() and get_js() here, in order to have new files added
   // during this request to be loaded by the page. We only want to send back
   // files that the page hasn't already loaded, so we implement simple diffing
   // logic using array_diff_key().
@@ -244,14 +245,14 @@ function ajax_render($commands = array()) {
       $items[$type] = array();
     }
     else {
-      $function = 'drupal_add_' . $type;
+      $function = 'Drupal\add_' . $type;
       $items[$type] = $function();
-      drupal_alter($type, $items[$type]);
+      alter($type, $items[$type]);
       // @todo Inline CSS and JS items are indexed numerically. These can't be
       //   reliably diffed with array_diff_key(), since the number can change
       //   due to factors unrelated to the inline content, so for now, we strip
       //   the inline items from Ajax responses, and can add support for them
-      //   when drupal_add_css() and drupal_add_js() are changed to using md5()
+      //   when add_css() and add_js() are changed to using md5()
       //   or some other hash of the inline content.
       foreach ($items[$type] as $key => $item) {
         if (is_numeric($key)) {
@@ -270,9 +271,9 @@ function ajax_render($commands = array()) {
   if (isset($items['js']['settings'])) {
     unset($items['js']['settings']);
   }
-  $styles = drupal_get_css($items['css'], TRUE);
-  $scripts_footer = drupal_get_js('footer', $items['js'], TRUE);
-  $scripts_header = drupal_get_js('header', $items['js'], TRUE);
+  $styles = get_css($items['css'], TRUE);
+  $scripts_footer = get_js('footer', $items['js'], TRUE);
+  $scripts_header = get_js('header', $items['js'], TRUE);
 
   $extra_commands = array();
   if (!empty($styles)) {
@@ -289,14 +290,14 @@ function ajax_render($commands = array()) {
   }
 
   // Now add a command to merge changes and additions to Drupal.settings.
-  $scripts = drupal_add_js();
+  $scripts = add_js();
   if (!empty($scripts['settings'])) {
     $settings = $scripts['settings'];
     array_unshift($commands, ajax_command_settings(call_user_func_array('array_merge_recursive', $settings['data']), TRUE));
   }
 
   // Allow modules to alter any Ajax response.
-  drupal_alter('ajax_render', $commands);
+  alter('ajax_render', $commands);
 
   return drupal_json_encode($commands);
 }
@@ -336,7 +337,7 @@ function ajax_get_form() {
 
   // When a form is rebuilt after Ajax processing, its #build_id and #action
   // should not change.
-  // @see drupal_rebuild_form()
+  // @see rebuild_form()
   $form_state['rebuild_info']['copy']['#build_id'] = TRUE;
   $form_state['rebuild_info']['copy']['#action'] = TRUE;
 
@@ -369,7 +370,7 @@ function ajax_get_form() {
  */
 function ajax_form_callback() {
   list($form, $form_state) = ajax_get_form();
-  drupal_process_form($form['#form_id'], $form, $form_state);
+  process_form($form['#form_id'], $form, $form_state);
 
   // We need to return the part of the form (or some other content) that needs
   // to be re-rendered so the browser can update the page with changed content.
@@ -380,8 +381,11 @@ function ajax_form_callback() {
   if (!empty($form_state['triggering_element'])) {
     $callback = $form_state['triggering_element']['#ajax']['callback'];
   }
-  if (!empty($callback) && function_exists($callback)) {
-    return $callback($form, $form_state);
+  if (!empty($callback)) {
+    $function = 'Drupal\\' . $callback;
+    if (function_exists($function)) {
+      return $function($form, $form_state);
+    }
   }
 }
 
@@ -420,7 +424,7 @@ function ajax_base_page_theme() {
     // to see the default theme, token validation isn't required for that, and
     // bypassing it allows most use-cases to work even when accessed from the
     // page cache.
-    if ($theme === variable_get('theme_default', 'stark') || drupal_valid_token($token, $theme)) {
+    if ($theme === variable_get('theme_default', 'stark') || valid_token($token, $theme)) {
       return $theme;
     }
   }
@@ -429,7 +433,7 @@ function ajax_base_page_theme() {
 /**
  * Packages and sends the result of a page callback as an Ajax response.
  *
- * This function is the equivalent of drupal_deliver_html_page(), but for Ajax
+ * This function is the equivalent of deliver_html_page(), but for Ajax
  * requests. Like that function, it:
  * - Adds needed HTTP headers.
  * - Prints rendered output.
@@ -442,7 +446,7 @@ function ajax_base_page_theme() {
  *   - A string of HTML content.
  *   - A renderable array of content.
  *
- * @see drupal_deliver_html_page()
+ * @see deliver_html_page()
  */
 function ajax_deliver($page_callback_result) {
   // Browsers do not allow JavaScript to read the contents of a user's local
@@ -456,17 +460,17 @@ function ajax_deliver($page_callback_result) {
 
   // Emit a Content-Type HTTP header if none has been added by the page callback
   // or by a wrapping delivery callback.
-  if (is_null(drupal_get_http_header('Content-Type'))) {
+  if (is_null(get_http_header('Content-Type'))) {
     if (!$iframe_upload) {
       // Standard JSON can be returned to a browser's XHR object, and to
       // non-browser user agents.
       // @see http://www.ietf.org/rfc/rfc4627.txt?number=4627
-      drupal_add_http_header('Content-Type', 'application/json; charset=utf-8');
+      add_http_header('Content-Type', 'application/json; charset=utf-8');
     }
     else {
       // Browser IFRAMEs expect HTML. With most other content types, Internet
       // Explorer presents the user with a download prompt.
-      drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
+      add_http_header('Content-Type', 'text/html; charset=utf-8');
     }
   }
 
@@ -562,23 +566,23 @@ function ajax_prepare_response($page_callback_result) {
 /**
  * Performs end-of-Ajax-request tasks.
  *
- * This function is the equivalent of drupal_page_footer(), but for Ajax
+ * This function is the equivalent of page_footer(), but for Ajax
  * requests.
  *
- * @see drupal_page_footer()
+ * @see page_footer()
  */
 function ajax_footer() {
   // Even for Ajax requests, invoke hook_exit() implementations. There may be
   // modules that need very fast Ajax responses, and therefore, run Ajax
   // requests with an early bootstrap.
-  if (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update')) {
+  if (get_bootstrap_phase() == BOOTSTRAP_FULL && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update')) {
     module_invoke_all('exit');
   }
 
   // Commit the user session. See above comment about the possibility of this
   // function running without session.inc loaded.
-  if (function_exists('drupal_session_commit')) {
-    drupal_session_commit();
+  if (function_exists('Drupal\session_commit')) {
+    session_commit();
   }
 }
 
diff --git a/core/includes/archiver.inc b/core/includes/archiver.inc
index 835d46f..db16be6 100644
--- a/core/includes/archiver.inc
+++ b/core/includes/archiver.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/includes/authorize.inc b/core/includes/authorize.inc
index 21e9a11..eb2aea2 100644
--- a/core/includes/authorize.inc
+++ b/core/includes/authorize.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -27,7 +29,7 @@ function authorize_filetransfer_form($form, &$form_state) {
 
   // Get all the available ways to transfer files.
   if (empty($_SESSION['authorize_filetransfer_info'])) {
-    drupal_set_message(t('Unable to continue, no available methods of file transfer'), 'error');
+    set_message(t('Unable to continue, no available methods of file transfer'), 'error');
     return array();
   }
   $available_backends = $_SESSION['authorize_filetransfer_info'];
@@ -297,11 +299,11 @@ function authorize_run_operation($filetransfer) {
   unset($_SESSION['authorize_operation']);
 
   if (!empty($operation['page_title'])) {
-    drupal_set_title($operation['page_title']);
+    set_title($operation['page_title']);
   }
 
-  require_once DRUPAL_ROOT . '/' . $operation['file'];
-  call_user_func_array($operation['callback'], array_merge(array($filetransfer), $operation['arguments']));
+  require_once ROOT . '/' . $operation['file'];
+  call_user_func_array('Drupal\\' . $operation['callback'], array_merge(array($filetransfer), $operation['arguments']));
 }
 
 /**
@@ -324,8 +326,9 @@ function authorize_get_filetransfer($backend, $settings = array()) {
       $file = $backend_info['file path'] . '/' . $backend_info['file'];
       require_once $file;
     }
-    if (class_exists($backend_info['class'])) {
-      $filetransfer = $backend_info['class']::factory(DRUPAL_ROOT, $settings);
+    $class = 'Drupal\\' . $backend_info['class'];
+    if (class_exists($class)) {
+      $filetransfer = $class::factory(ROOT, $settings);
     }
   }
   return $filetransfer;
diff --git a/core/includes/batch.inc b/core/includes/batch.inc
index 83ddd30..d69eaad 100644
--- a/core/includes/batch.inc
+++ b/core/includes/batch.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -27,7 +28,7 @@
 function batch_load($id) {
   $batch = db_query("SELECT batch FROM {batch} WHERE bid = :bid AND token = :token", array(
     ':bid' => $id,
-    ':token' => drupal_get_token($id),
+    ':token' => get_token($id),
   ))->fetchField();
   if ($batch) {
     return unserialize($batch);
@@ -51,19 +52,19 @@ function _batch_page() {
   if (!$batch) {
     $batch = batch_load($_REQUEST['id']);
     if (!$batch) {
-      drupal_set_message(t('No active batch.'), 'error');
-      drupal_goto();
+      set_message(t('No active batch.'), 'error');
+      redirect();
     }
   }
 
   // Register database update for the end of processing.
-  drupal_register_shutdown_function('_batch_shutdown');
+  drupal_register_shutdown_function('Drupal\_batch_shutdown');
 
   // Add batch-specific CSS.
   foreach ($batch['sets'] as $batch_set) {
     if (isset($batch_set['css'])) {
       foreach ($batch_set['css'] as $css) {
-        drupal_add_css($css);
+        add_css($css);
       }
     }
   }
@@ -124,7 +125,7 @@ function _batch_progress_page_js() {
   $batch = batch_get();
 
   $current_set = _batch_current_set();
-  drupal_set_title($current_set['title'], PASS_THROUGH);
+  set_title($current_set['title'], PASS_THROUGH);
 
   // Merge required query parameters for batch processing into those provided by
   // batch_set() or hook_batch_alter().
@@ -137,8 +138,8 @@ function _batch_progress_page_js() {
       'uri' => url($batch['url'], $batch['url_options']),
     ),
   );
-  drupal_add_js($js_setting, 'setting');
-  drupal_add_library('system', 'drupal.batch');
+  add_js($js_setting, 'setting');
+  add_library('system', 'drupal.batch');
 
   return '<div id="progress"></div>';
 }
@@ -152,15 +153,15 @@ function _batch_progress_page_js() {
 function _batch_do() {
   // HTTP POST required.
   if ($_SERVER['REQUEST_METHOD'] != 'POST') {
-    drupal_set_message(t('HTTP POST is required.'), 'error');
-    drupal_set_title(t('Error'));
+    set_message(t('HTTP POST is required.'), 'error');
+    set_title(t('Error'));
     return '';
   }
 
   // Perform actual processing.
   list($percentage, $message) = _batch_process();
 
-  drupal_json_output(array('status' => TRUE, 'percentage' => $percentage, 'message' => $message));
+  json_output(array('status' => TRUE, 'percentage' => $percentage, 'message' => $message));
 }
 
 /**
@@ -172,7 +173,7 @@ function _batch_progress_page_nojs() {
   $batch = &batch_get();
 
   $current_set = _batch_current_set();
-  drupal_set_title($current_set['title'], PASS_THROUGH);
+  set_title($current_set['title'], PASS_THROUGH);
 
   $new_op = 'do_nojs';
 
@@ -222,7 +223,7 @@ function _batch_progress_page_nojs() {
       'content' => '0; URL=' . $url,
     ),
   );
-  drupal_add_html_head($element, 'batch_progress_meta_refresh');
+  add_html_head($element, 'batch_progress_meta_refresh');
 
   return theme('progress_bar', array('percent' => $percentage, 'message' => $message));
 }
@@ -245,7 +246,7 @@ function _batch_process() {
   $set_changed = TRUE;
 
   // If this batch was marked for progressive execution (e.g. forms submitted by
-  // drupal_form_submit()), initialize a timer to determine whether we need to
+  // form_submit()), initialize a timer to determine whether we need to
   // proceed with the same batch phase when a processing time of 1 second has
   // been exceeded.
   if ($batch['progressive']) {
@@ -263,7 +264,7 @@ function _batch_process() {
     // request, we check if it requires an additional file for functions
     // definitions.
     if ($set_changed && isset($current_set['file']) && is_file($current_set['file'])) {
-      include_once DRUPAL_ROOT . '/' . $current_set['file'];
+      include_once ROOT . '/' . $current_set['file'];
     }
 
     $task_message = '';
@@ -281,7 +282,7 @@ function _batch_process() {
         'finished' => &$finished,
         'message'  => &$task_message,
       );
-      call_user_func_array($function, array_merge($args, array(&$batch_context)));
+      call_user_func_array('Drupal\\' . $function, array_merge($args, array(&$batch_context)));
 
       if ($finished >= 1) {
         // Make sure this step is not counted twice when computing $current.
@@ -435,10 +436,13 @@ function _batch_next_set() {
   if (isset($batch['sets'][$batch['current_set'] + 1])) {
     $batch['current_set']++;
     $current_set = &_batch_current_set();
-    if (isset($current_set['form_submit']) && ($function = $current_set['form_submit']) && function_exists($function)) {
-      // We use our stored copies of $form and $form_state to account for
-      // possible alterations by previous form submit handlers.
-      $function($batch['form_state']['complete_form'], $batch['form_state']);
+    if (isset($current_set['form_submit'])) {
+      $function = 'Drupal\\' . $current_set['form_submit'];
+      if (function_exists($function)) {
+        // We use our stored copies of $form and $form_state to account for
+        // possible alterations by previous form submit handlers.
+        $function($batch['form_state']['complete_form'], $batch['form_state']);
+      }
     }
     return TRUE;
   }
@@ -458,12 +462,13 @@ function _batch_finished() {
     if (isset($batch_set['finished'])) {
       // Check if the set requires an additional file for function definitions.
       if (isset($batch_set['file']) && is_file($batch_set['file'])) {
-        include_once DRUPAL_ROOT . '/' . $batch_set['file'];
+        include_once ROOT . '/' . $batch_set['file'];
       }
-      if (function_exists($batch_set['finished'])) {
+      $function = 'Drupal\\' . $batch_set['finished'];
+      if (function_exists($function)) {
         $queue = _batch_queue($batch_set);
         $operations = $queue->getAllItems();
-        $batch_set['finished']($batch_set['success'], $batch_set['results'], $operations, format_interval($batch_set['elapsed'] / 1000));
+        $function($batch_set['success'], $batch_set['results'], $operations, format_interval($batch_set['elapsed'] / 1000));
       }
     }
   }
@@ -507,16 +512,16 @@ function _batch_finished() {
       }
     }
 
-    // Use drupal_redirect_form() to handle the redirection logic.
-    drupal_redirect_form($_batch['form_state']);
+    // Use redirect_form() to handle the redirection logic.
+    redirect_form($_batch['form_state']);
 
     // If no redirection happened, redirect to the originating page. In case the
     // form needs to be rebuilt, save the final $form_state for
-    // drupal_build_form().
+    // build_form().
     if (!empty($_batch['form_state']['rebuild'])) {
       $_SESSION['batch_form_state'] = $_batch['form_state'];
     }
-    $function = $_batch['redirect_callback'];
+    $function = 'Drupal\\' . $_batch['redirect_callback'];
     if (function_exists($function)) {
       $function($_batch['source_url'], array('query' => array('op' => 'finish', 'id' => $_batch['id'])));
     }
diff --git a/core/includes/batch.queue.inc b/core/includes/batch.queue.inc
index ed290ee..49f9306 100644
--- a/core/includes/batch.queue.inc
+++ b/core/includes/batch.queue.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -37,7 +38,7 @@ class BatchQueue extends SystemQueue {
   /**
    * Retrieves all remaining items in the queue.
    *
-   * This is specific to Batch API and is not part of the DrupalQueueInterface.
+   * This is specific to Batch API and is not part of the QueueInterface.
    */
   public function getAllItems() {
     $result = array();
@@ -72,7 +73,7 @@ class BatchMemoryQueue extends MemoryQueue {
   /**
    * Retrieves all remaining items in the queue.
    *
-   * This is specific to Batch API and is not part of the DrupalQueueInterface.
+   * This is specific to Batch API and is not part of the QueueInterface.
    */
   public function getAllItems() {
     $result = array();
diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 31b2aa1..7e17713 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -1,5 +1,6 @@
 <?php
-
+namespace Drupal;
+use ArrayAccess, Exception, stdClass;
 use Symfony\Component\ClassLoader\UniversalClassLoader;
 use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
 
@@ -16,17 +17,17 @@ const VERSION = '8.0-dev';
 /**
  * Core API compatibility.
  */
-const DRUPAL_CORE_COMPATIBILITY = '8.x';
+const CORE_COMPATIBILITY = '8.x';
 
 /**
  * Minimum supported version of PHP.
  */
-const DRUPAL_MINIMUM_PHP = '5.3.2';
+const MINIMUM_PHP = '5.3.2';
 
 /**
  * Minimum recommended value of PHP memory_limit.
  */
-const DRUPAL_MINIMUM_PHP_MEMORY_LIMIT = '32M';
+const MINIMUM_PHP_MEMORY_LIMIT = '32M';
 
 /**
  * Indicates that the item should never be removed unless explicitly selected.
@@ -107,59 +108,59 @@ const WATCHDOG_DEBUG = 7;
 /**
  * First bootstrap phase: initialize configuration.
  */
-const DRUPAL_BOOTSTRAP_CONFIGURATION = 0;
+const BOOTSTRAP_CONFIGURATION = 0;
 
 /**
  * Second bootstrap phase: try to serve a cached page.
  */
-const DRUPAL_BOOTSTRAP_PAGE_CACHE = 1;
+const BOOTSTRAP_PAGE_CACHE = 1;
 
 /**
  * Third bootstrap phase: initialize database layer.
  */
-const DRUPAL_BOOTSTRAP_DATABASE = 2;
+const BOOTSTRAP_DATABASE = 2;
 
 /**
  * Fourth bootstrap phase: initialize the variable system.
  */
-const DRUPAL_BOOTSTRAP_VARIABLES = 3;
+const BOOTSTRAP_VARIABLES = 3;
 
 /**
  * Fifth bootstrap phase: initialize session handling.
  */
-const DRUPAL_BOOTSTRAP_SESSION = 4;
+const BOOTSTRAP_SESSION = 4;
 
 /**
  * Sixth bootstrap phase: set up the page header.
  */
-const DRUPAL_BOOTSTRAP_PAGE_HEADER = 5;
+const BOOTSTRAP_PAGE_HEADER = 5;
 
 /**
  * Seventh bootstrap phase: find out language of the page.
  */
-const DRUPAL_BOOTSTRAP_LANGUAGE = 6;
+const BOOTSTRAP_LANGUAGE = 6;
 
 /**
  * Final bootstrap phase: Drupal is fully loaded; validate and fix input data.
  */
-const DRUPAL_BOOTSTRAP_FULL = 7;
+const BOOTSTRAP_FULL = 7;
 
 /**
  * Role ID for anonymous users; should match what's in the "role" table.
  */
-const DRUPAL_ANONYMOUS_RID = 1;
+const ANONYMOUS_RID = 1;
 
 /**
  * Role ID for authenticated users; should match what's in the "role" table.
  */
-const DRUPAL_AUTHENTICATED_RID = 2;
+const AUTHENTICATED_RID = 2;
 
 /**
  * The number of bytes in a kilobyte.
  *
  * For more information, visit http://en.wikipedia.org/wiki/Kilobyte.
  */
-const DRUPAL_KILOBYTE = 1024;
+const KILOBYTE = 1024;
 
 /**
  * System language (only applicable to UI).
@@ -213,12 +214,12 @@ const LANGUAGE_RTL = 1;
 define('REQUEST_TIME', (int) $_SERVER['REQUEST_TIME']);
 
 /**
- * Flag for drupal_set_title(); text is not sanitized, so run check_plain().
+ * Flag for set_title(); text is not sanitized, so run check_plain().
  */
 const CHECK_PLAIN = 0;
 
 /**
- * Flag for drupal_set_title(); text has already been sanitized.
+ * Flag for set_title(); text has already been sanitized.
  */
 const PASS_THROUGH = -1;
 
@@ -237,7 +238,7 @@ const REGISTRY_WRITE_LOOKUP_CACHE = 2;
  *
  * @see http://php.net/manual/en/language.functions.php
  */
-const DRUPAL_PHP_FUNCTION_PATTERN = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*';
+const PHP_FUNCTION_PATTERN = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*';
 
 /**
  * Provides a caching wrapper to be used in place of large array structures.
@@ -251,9 +252,9 @@ const DRUPAL_PHP_FUNCTION_PATTERN = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*';
  * static caches of that same data.
  *
  * Note that array_* functions do not work with ArrayAccess. Systems using
- * DrupalCacheArray should use this only internally. If providing API functions
+ * CacheArray should use this only internally. If providing API functions
  * that return the full array, this can be cached separately or returned
- * directly. However since DrupalCacheArray holds partial content by design, it
+ * directly. However since CacheArray holds partial content by design, it
  * should be a normal PHP array or otherwise contain the full structure.
  *
  * Note also that due to limitations in PHP prior to 5.3.4, it is impossible to
@@ -294,7 +295,7 @@ const DRUPAL_PHP_FUNCTION_PATTERN = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*';
  *
  * @see SchemaCache
  */
-abstract class DrupalCacheArray implements ArrayAccess {
+abstract class CacheArray implements ArrayAccess {
 
   /**
    * A cid to pass to cache()->set() and cache()->get().
@@ -317,7 +318,7 @@ abstract class DrupalCacheArray implements ArrayAccess {
   protected $storage = array();
 
   /**
-   * Constructs a DrupalCacheArray object.
+   * Constructs a CacheArray object.
    *
    * @param $cid
    *   The cid for the array being cached.
@@ -424,7 +425,7 @@ abstract class DrupalCacheArray implements ArrayAccess {
   }
 
   /**
-   * Destructs the DrupalCacheArray object.
+   * Destructs the CacheArray object.
    */
   public function __destruct() {
     $data = array();
@@ -605,9 +606,9 @@ function find_conf_path($http_host, $script_name, $require_settings = TRUE) {
   $confdir = 'sites';
 
   $sites = array();
-  if (file_exists(DRUPAL_ROOT . '/' . $confdir . '/sites.php')) {
+  if (file_exists(ROOT . '/' . $confdir . '/sites.php')) {
     // This will overwrite $sites with the desired mappings.
-    include(DRUPAL_ROOT . '/' . $confdir . '/sites.php');
+    include(ROOT . '/' . $confdir . '/sites.php');
   }
 
   $uri = explode('/', $script_name);
@@ -615,10 +616,10 @@ function find_conf_path($http_host, $script_name, $require_settings = TRUE) {
   for ($i = count($uri) - 1; $i > 0; $i--) {
     for ($j = count($server); $j > 0; $j--) {
       $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i));
-      if (isset($sites[$dir]) && file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $sites[$dir])) {
+      if (isset($sites[$dir]) && file_exists(ROOT . '/' . $confdir . '/' . $sites[$dir])) {
         $dir = $sites[$dir];
       }
-      if (file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $dir . '/settings.php') || (!$require_settings && file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $dir))) {
+      if (file_exists(ROOT . '/' . $confdir . '/' . $dir . '/settings.php') || (!$require_settings && file_exists(ROOT . '/' . $confdir . '/' . $dir))) {
         $conf = "$confdir/$dir";
         return $conf;
       }
@@ -662,7 +663,7 @@ function find_conf_path($http_host, $script_name, $require_settings = TRUE) {
  * @see request_uri()
  * @see ip_address()
  */
-function drupal_override_server_variables($variables = array()) {
+function override_server_variables($variables = array()) {
   // Allow the provided URL to override any existing values in $_SERVER.
   if (isset($variables['url'])) {
     $url = parse_url($variables['url']);
@@ -693,7 +694,7 @@ function drupal_override_server_variables($variables = array()) {
 /**
  * Initializes the PHP environment.
  */
-function drupal_environment_initialize() {
+function environment_initialize() {
   if (!isset($_SERVER['HTTP_REFERER'])) {
     $_SERVER['HTTP_REFERER'] = '';
   }
@@ -706,7 +707,7 @@ function drupal_environment_initialize() {
     // in hostnames. See RFC 952 (and RFC 2181).
     // $_SERVER['HTTP_HOST'] is lowercased here per specifications.
     $_SERVER['HTTP_HOST'] = strtolower($_SERVER['HTTP_HOST']);
-    if (!drupal_valid_http_host($_SERVER['HTTP_HOST'])) {
+    if (!valid_http_host($_SERVER['HTTP_HOST'])) {
       // HTTP_HOST is invalid, e.g. if containing slashes it may be an attack.
       header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
       exit;
@@ -755,22 +756,22 @@ function drupal_environment_initialize() {
  * @return
  *  TRUE if only containing valid characters, or FALSE otherwise.
  */
-function drupal_valid_http_host($host) {
+function valid_http_host($host) {
   return preg_match('/^\[?(?:[a-zA-Z0-9-:\]_]+\.?)+$/', $host);
 }
 
 /**
  * Sets the base URL, cookie domain, and session name from configuration.
  */
-function drupal_settings_initialize() {
+function settings_initialize() {
   global $base_url, $base_path, $base_root;
 
   // Export the following settings.php variables to the global namespace
-  global $databases, $cookie_domain, $conf, $installed_profile, $update_free_access, $db_url, $db_prefix, $drupal_hash_salt, $is_https, $base_secure_url, $base_insecure_url;
+  global $databases, $cookie_domain, $conf, $installed_profile, $update_free_access, $db_url, $db_prefix, $hash_salt, $is_https, $base_secure_url, $base_insecure_url;
   $conf = array();
 
-  if (file_exists(DRUPAL_ROOT . '/' . conf_path() . '/settings.php')) {
-    include_once DRUPAL_ROOT . '/' . conf_path() . '/settings.php';
+  if (file_exists(ROOT . '/' . conf_path() . '/settings.php')) {
+    include_once ROOT . '/' . conf_path() . '/settings.php';
   }
   $is_https = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
 
@@ -823,7 +824,7 @@ function drupal_settings_initialize() {
     // to use the same session identifiers across http and https.
     list( , $session_name) = explode('://', $base_url, 2);
     // HTTP_HOST can be modified by a visitor, but we already sanitized it
-    // in drupal_settings_initialize().
+    // in settings_initialize().
     if (!empty($_SERVER['HTTP_HOST'])) {
       $cookie_domain = $_SERVER['HTTP_HOST'];
       // Strip leading periods, www., and port numbers from cookie domain.
@@ -868,7 +869,7 @@ function drupal_settings_initialize() {
  * sites/all/modules/foo/foo.module
  * sites/example.com/modules/foo/foo.module
  *
- * Calling drupal_get_filename('module', 'foo') will give you one of
+ * Calling get_filename('module', 'foo') will give you one of
  * the above, depending on where the module is located.
  *
  * @param $type
@@ -882,7 +883,7 @@ function drupal_settings_initialize() {
  * @return
  *   The filename of the requested item.
  */
-function drupal_get_filename($type, $name, $filename = NULL) {
+function get_filename($type, $name, $filename = NULL) {
   // The location of files will not change during the request, so do not use
   // drupal_static().
   static $files = array(), $dirs = array();
@@ -908,9 +909,9 @@ function drupal_get_filename($type, $name, $filename = NULL) {
   // when a database connection fails.
   else {
     try {
-      if (function_exists('db_query')) {
+      if (function_exists('Drupal\db_query')) {
         $file = db_query("SELECT filename FROM {system} WHERE name = :name AND type = :type", array(':name' => $name, ':type' => $type))->fetchField();
-        if (file_exists(DRUPAL_ROOT . '/' . $file)) {
+        if (file_exists(ROOT . '/' . $file)) {
           $files[$type][$name] = $file;
         }
       }
@@ -938,14 +939,14 @@ function drupal_get_filename($type, $name, $filename = NULL) {
 
       if (!isset($dirs[$dir][$extension])) {
         $dirs[$dir][$extension] = TRUE;
-        if (!function_exists('drupal_system_listing')) {
-          require_once DRUPAL_ROOT . '/core/includes/common.inc';
+        if (!function_exists('Drupal\system_listing')) {
+          require_once ROOT . '/core/includes/common.inc';
         }
         // Scan the appropriate directories for all files with the requested
         // extension, not just the file we are currently looking for. This
         // prevents unnecessary scans from being repeated when this function is
         // called more than once in the same page request.
-        $matches = drupal_system_listing("/^" . DRUPAL_PHP_FUNCTION_PATTERN . "\.$extension$/", $dir, 'name', 0);
+        $matches = system_listing("/^" . PHP_FUNCTION_PATTERN . "\.$extension$/", $dir, 'name', 0);
         foreach ($matches as $matched_name => $file) {
           $files[$type][$matched_name] = $file->uri;
         }
@@ -1084,7 +1085,7 @@ function variable_del($name) {
  * @return
  *   The cache object, if the page was found in the cache, NULL otherwise.
  */
-function drupal_page_get_cache($check_only = FALSE) {
+function page_get_cache($check_only = FALSE) {
   global $base_root;
   static $cache_hit = FALSE;
 
@@ -1092,7 +1093,7 @@ function drupal_page_get_cache($check_only = FALSE) {
     return $cache_hit;
   }
 
-  if (drupal_page_is_cacheable()) {
+  if (page_is_cacheable()) {
     $cache = cache('page')->get($base_root . request_uri());
     if ($cache !== FALSE) {
       $cache_hit = TRUE;
@@ -1110,14 +1111,14 @@ function drupal_page_get_cache($check_only = FALSE) {
  * @return
  *   TRUE if the current page can be cached, FALSE otherwise.
  */
-function drupal_page_is_cacheable($allow_caching = NULL) {
+function page_is_cacheable($allow_caching = NULL) {
   $allow_caching_static = &drupal_static(__FUNCTION__, TRUE);
   if (isset($allow_caching)) {
     $allow_caching_static = $allow_caching;
   }
 
   return $allow_caching_static && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD')
-    && !drupal_is_cli();
+    && !is_cli();
 }
 
 /**
@@ -1137,7 +1138,7 @@ function bootstrap_invoke_all($hook) {
   // make sure that its internal cache is primed with the bootstrap modules
   // only.
   foreach (module_list(FALSE, TRUE) as $module) {
-    drupal_load('module', $module);
+    load('module', $module);
     module_invoke($module, $hook);
   }
 }
@@ -1155,7 +1156,7 @@ function bootstrap_invoke_all($hook) {
  * @return
  *   TRUE if the item is loaded or has already been loaded.
  */
-function drupal_load($type, $name) {
+function load($type, $name) {
   // Once a file is included this can't be reversed during a request so do not
   // use drupal_static() here.
   static $files = array();
@@ -1164,10 +1165,10 @@ function drupal_load($type, $name) {
     return TRUE;
   }
 
-  $filename = drupal_get_filename($type, $name);
+  $filename = get_filename($type, $name);
 
   if ($filename) {
-    include_once DRUPAL_ROOT . '/' . $filename;
+    include_once ROOT . '/' . $filename;
     $files[$type][$name] = TRUE;
 
     return TRUE;
@@ -1191,12 +1192,12 @@ function drupal_load($type, $name) {
  * @param $append
  *   Whether to append the value to an existing header or to replace it.
  */
-function drupal_add_http_header($name, $value, $append = FALSE) {
+function add_http_header($name, $value, $append = FALSE) {
   // The headers as name/value pairs.
   $headers = &drupal_static('drupal_http_headers', array());
 
   $name_lower = strtolower($name);
-  _drupal_set_preferred_header_name($name);
+  _set_preferred_header_name($name);
 
   if ($value === FALSE) {
     $headers[$name_lower] = FALSE;
@@ -1209,7 +1210,7 @@ function drupal_add_http_header($name, $value, $append = FALSE) {
   else {
     $headers[$name_lower] = $value;
   }
-  drupal_send_headers(array($name => $headers[$name_lower]), TRUE);
+  send_headers(array($name => $headers[$name_lower]), TRUE);
 }
 
 /**
@@ -1223,7 +1224,7 @@ function drupal_add_http_header($name, $value, $append = FALSE) {
  *   A string containing the header value, or FALSE if the header has been set,
  *   or NULL if the header has not been set.
  */
-function drupal_get_http_header($name = NULL) {
+function get_http_header($name = NULL) {
   $headers = &drupal_static('drupal_http_headers', array());
   if (isset($name)) {
     $name = strtolower($name);
@@ -1240,7 +1241,7 @@ function drupal_get_http_header($name = NULL) {
  * Header names are case-insensitive, but for maximum compatibility they should
  * follow "common form" (see RFC 2617, section 4.2).
  */
-function _drupal_set_preferred_header_name($name = NULL) {
+function _set_preferred_header_name($name = NULL) {
   static $header_names = array();
 
   if (!isset($name)) {
@@ -1252,23 +1253,23 @@ function _drupal_set_preferred_header_name($name = NULL) {
 /**
  * Sends the HTTP response headers that were previously set, adding defaults.
  *
- * Headers are set in drupal_add_http_header(). Default headers are not set
- * if they have been replaced or unset using drupal_add_http_header().
+ * Headers are set in add_http_header(). Default headers are not set
+ * if they have been replaced or unset using add_http_header().
  *
  * @param $default_headers
  *   An array of headers as name/value pairs.
  * @param $single
  *   If TRUE and headers have already be sent, send only the specified header.
  */
-function drupal_send_headers($default_headers = array(), $only_default = FALSE) {
+function send_headers($default_headers = array(), $only_default = FALSE) {
   $headers_sent = &drupal_static(__FUNCTION__, FALSE);
-  $headers = drupal_get_http_header();
+  $headers = get_http_header();
   if ($only_default && $headers_sent) {
     $headers = array();
   }
   $headers_sent = TRUE;
 
-  $header_names = _drupal_set_preferred_header_name();
+  $header_names = _set_preferred_header_name();
   foreach ($default_headers as $name => $value) {
     $name_lower = strtolower($name);
     if (!isset($headers[$name_lower])) {
@@ -1312,9 +1313,9 @@ function drupal_send_headers($default_headers = array(), $only_default = FALSE)
  * the client think that the anonymous and authenticated pageviews are
  * identical.
  *
- * @see drupal_page_set_cache()
+ * @see page_set_cache()
  */
-function drupal_page_header() {
+function page_header() {
   $headers_sent = &drupal_static(__FUNCTION__, FALSE);
   if ($headers_sent) {
     return TRUE;
@@ -1327,7 +1328,7 @@ function drupal_page_header() {
     'Cache-Control' => 'no-cache, must-revalidate, post-check=0, pre-check=0',
     'ETag' => '"' . REQUEST_TIME . '"',
   );
-  drupal_send_headers($default_headers);
+  send_headers($default_headers);
 }
 
 /**
@@ -1335,22 +1336,22 @@ function drupal_page_header() {
  *
  * The headers allow as much as possible in proxies and browsers without any
  * particular knowledge about the pages. Modules can override these headers
- * using drupal_add_http_header().
+ * using add_http_header().
  *
  * If the request is conditional (using If-Modified-Since and If-None-Match),
  * and the conditions match those currently in the cache, a 304 Not Modified
  * response is sent.
  */
-function drupal_serve_page_from_cache(stdClass $cache) {
+function serve_page_from_cache(stdClass $cache) {
   // Negotiate whether to use compression.
   $page_compression = variable_get('page_compression', TRUE) && extension_loaded('zlib');
   $return_compressed = $page_compression && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE;
 
   // Get headers set in hook_boot(). Keys are lower-case.
-  $hook_boot_headers = drupal_get_http_header();
+  $hook_boot_headers = get_http_header();
 
   // Headers generated in this function, that may be replaced or unset using
-  // drupal_add_http_headers(). Keys are mixed-case.
+  // add_http_headers(). Keys are mixed-case.
   $default_headers = array();
 
   foreach ($cache->data['headers'] as $name => $value) {
@@ -1359,7 +1360,7 @@ function drupal_serve_page_from_cache(stdClass $cache) {
     // headers set in hook_boot().
     $name_lower = strtolower($name);
     if (in_array($name_lower, array('content-location', 'expires', 'cache-control', 'vary')) && !isset($hook_boot_headers[$name_lower])) {
-      drupal_add_http_header($name, $value);
+      add_http_header($name, $value);
       unset($cache->data['headers'][$name]);
     }
   }
@@ -1384,13 +1385,13 @@ function drupal_serve_page_from_cache(stdClass $cache) {
       && $if_none_match == $etag // etag must match
       && $if_modified_since == $cache->created) {  // if-modified-since must match
     header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
-    drupal_send_headers($default_headers);
+    send_headers($default_headers);
     return;
   }
 
   // Send the remaining headers.
   foreach ($cache->data['headers'] as $name => $value) {
-    drupal_add_http_header($name, $value);
+    add_http_header($name, $value);
   }
 
   $default_headers['Last-Modified'] = gmdate(DATE_RFC1123, $cache->created);
@@ -1401,7 +1402,7 @@ function drupal_serve_page_from_cache(stdClass $cache) {
   // 2616, section 14.9.3).
   $default_headers['Expires'] = 'Sun, 19 Nov 1978 05:00:00 GMT';
 
-  drupal_send_headers($default_headers);
+  send_headers($default_headers);
 
   // Allow HTTP proxies to cache pages for anonymous users without a session
   // cookie. The Vary header is used to indicates the set of request-header
@@ -1541,7 +1542,7 @@ function t($string, array $args = array(), array $options = array()) {
     $string = $custom_strings[$options['langcode']][$options['context']][$string];
   }
   // Translate with locale module if enabled.
-  elseif ($options['langcode'] != LANGUAGE_SYSTEM && ($options['langcode'] != 'en' || variable_get('locale_translate_english', FALSE)) && function_exists('locale')) {
+  elseif ($options['langcode'] != LANGUAGE_SYSTEM && ($options['langcode'] != 'en' || variable_get('locale_translate_english', FALSE)) && function_exists('Drupal\locale')) {
     $string = locale($string, $options['context'], $options['langcode']);
   }
   if (empty($args)) {
@@ -1567,7 +1568,7 @@ function t($string, array $args = array(), array $options = array()) {
  *   - @variable: Escaped to HTML using check_plain(). Use this for anything
  *     displayed on a page on the site.
  *   - %variable: Escaped as a placeholder for user-submitted content using
- *     drupal_placeholder(), which shows up as <em>emphasized</em> text.
+ *     placeholder(), which shows up as <em>emphasized</em> text.
  *
  * @see t()
  * @ingroup sanitization
@@ -1584,7 +1585,7 @@ function format_string($string, array $args = array()) {
       case '%':
       default:
         // Escaped and placeholder.
-        $args[$key] = drupal_placeholder($value);
+        $args[$key] = placeholder($value);
         break;
 
       case '!':
@@ -1607,7 +1608,7 @@ function format_string($string, array $args = array()) {
  *   An HTML safe version of $text, or an empty string if $text is not
  *   valid UTF-8.
  *
- * @see drupal_validate_utf8()
+ * @see validate_utf8()
  * @ingroup sanitization
  */
 function check_plain($text) {
@@ -1617,7 +1618,7 @@ function check_plain($text) {
 /**
  * Checks whether a string is valid UTF-8.
  *
- * All functions designed to filter input should use drupal_validate_utf8
+ * All functions designed to filter input should use validate_utf8
  * to ensure they operate on valid UTF-8 strings to prevent bypass of the
  * filter.
  *
@@ -1638,7 +1639,7 @@ function check_plain($text) {
  * @return
  *   TRUE if the text is valid UTF-8, FALSE if not.
  */
-function drupal_validate_utf8($text) {
+function validate_utf8($text) {
   if (strlen($text) == 0) {
     return TRUE;
   }
@@ -1690,20 +1691,20 @@ function request_uri() {
  *   information about the passed-in exception is used.
  * @param $variables
  *   Array of variables to replace in the message on display. Defaults to the
- *   return value of drupal_decode_exception().
+ *   return value of _decode_exception().
  * @param $severity
  *   The severity of the message, as per RFC 3164.
  * @param $link
  *   A link to associate with the message.
  *
  * @see watchdog()
- * @see drupal_decode_exception()
+ * @see _decode_exception()
  */
 function watchdog_exception($type, Exception $exception, $message = NULL, $variables = array(), $severity = WATCHDOG_ERROR, $link = NULL) {
 
    // Use a default value if $message is not set.
    if (empty($message)) {
-     // The exception message is run through check_plain() by _drupal_decode_exception().
+     // The exception message is run through check_plain() by _decode_exception().
      $message = '%type: !message in %function (line %line of %file).';
    }
    // $variables must be an array so that we can add the exception information.
@@ -1711,8 +1712,8 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia
      $variables = array();
    }
 
-   require_once DRUPAL_ROOT . '/core/includes/errors.inc';
-   $variables += _drupal_decode_exception($exception);
+   require_once ROOT . '/core/includes/errors.inc';
+   $variables += _decode_exception($exception);
    watchdog($type, $message, $variables, $severity, $link);
 }
 
@@ -1748,7 +1749,7 @@ function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NO
 
   // It is possible that the error handling will itself trigger an error. In that case, we could
   // end up in an infinite loop. To avoid that, we implement a simple static semaphore.
-  if (!$in_error_state && function_exists('module_implements')) {
+  if (!$in_error_state && function_exists('Drupal\module_implements')) {
     $in_error_state = TRUE;
 
     // Prepare the fields to be logged
@@ -1794,7 +1795,7 @@ function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NO
  *   If this is FALSE and the message is already set, then the message won't
  *   be repeated.
  */
-function drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE) {
+function set_message($message = NULL, $type = 'status', $repeat = TRUE) {
   if ($message) {
     if (!isset($_SESSION['messages'][$type])) {
       $_SESSION['messages'][$type] = array();
@@ -1805,7 +1806,7 @@ function drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE) {
     }
 
     // Mark this page as being uncacheable.
-    drupal_page_is_cacheable(FALSE);
+    page_is_cacheable(FALSE);
   }
 
   // Messages not set when DB connection fails.
@@ -1826,8 +1827,8 @@ function drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE) {
  *   or an empty array if there are no such messages. If $type is not passed,
  *   all message types are returned, or an empty array if none exist.
  */
-function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
-  if ($messages = drupal_set_message()) {
+function get_messages($type = NULL, $clear_queue = TRUE) {
+  if ($messages = set_message()) {
     if ($type) {
       if ($clear_queue) {
         unset($_SESSION['messages'][$type]);
@@ -1854,11 +1855,11 @@ function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
  * @return
  *   The current page's title.
  */
-function drupal_get_title() {
-  $title = drupal_set_title();
+function get_title() {
+  $title = set_title();
 
   // During a bootstrap, menu.inc is not included and thus we cannot provide a title.
-  if (!isset($title) && function_exists('menu_get_active_title')) {
+  if (!isset($title) && function_exists('Drupal\menu_get_active_title')) {
     $title = check_plain(menu_get_active_title());
   }
 
@@ -1882,7 +1883,7 @@ function drupal_get_title() {
  * @return
  *   The updated title of the current page.
  */
-function drupal_set_title($title = NULL, $output = CHECK_PLAIN) {
+function set_title($title = NULL, $output = CHECK_PLAIN) {
   $stored_title = &drupal_static(__FUNCTION__);
 
   if (isset($title)) {
@@ -1906,7 +1907,7 @@ function drupal_set_title($title = NULL, $output = CHECK_PLAIN) {
  * @return bool
  *   TRUE if access is denied, FALSE if access is allowed.
  */
-function drupal_is_denied($ip) {
+function is_denied($ip) {
   // Because this function is called on every page request, we first check
   // for an array of IP addresses in settings.php before querying the
   // database.
@@ -1933,9 +1934,9 @@ function drupal_is_denied($ip) {
  * @param $ip
  *   IP address to check. Prints a message and exits if access is denied.
  */
-function drupal_block_denied($ip) {
+function block_denied($ip) {
   // Deny access to blocked IP addresses - t() is not yet available.
-  if (drupal_is_denied($ip)) {
+  if (is_denied($ip)) {
     header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
     print 'Sorry, ' . check_plain(ip_address()) . ' has been banned.';
     exit();
@@ -1953,7 +1954,7 @@ function drupal_block_denied($ip) {
  * @param $count
  *   The number of characters (bytes) to return in the string.
  */
-function drupal_random_bytes($count)  {
+function random_bytes($count)  {
   // $random_state does not use drupal_static as it stores random bytes.
   static $random_state, $bytes;
   // Initialize on the first call. The contents of $_SERVER includes a mix of
@@ -2006,7 +2007,7 @@ function drupal_random_bytes($count)  {
  *   A base-64 encoded sha-256 hmac, with + replaced with -, / with _ and
  *   any = padding characters removed.
  */
-function drupal_hmac_base64($data, $key) {
+function hmac_base64($data, $key) {
   $hmac = base64_encode(hash_hmac('sha256', $data, $key, TRUE));
   // Modify the hmac so it's safe to use in URLs.
   return strtr($hmac, array('+' => '-', '/' => '_', '=' => ''));
@@ -2022,7 +2023,7 @@ function drupal_hmac_base64($data, $key) {
  *   A base-64 encoded sha-256 hash, with + replaced with -, / with _ and
  *   any = padding characters removed.
  */
-function drupal_hash_base64($data) {
+function hash_base64($data) {
   $hash = base64_encode(hash('sha256', $data, TRUE));
   // Modify the hash so it's safe to use in URLs.
   return strtr($hash, array('+' => '-', '/' => '_', '=' => ''));
@@ -2044,7 +2045,7 @@ function drupal_hash_base64($data) {
  * $incorrect = array_merge_recursive($link_options_1, $link_options_2);
  *
  * // This results in array('fragment' => 'y', 'attributes' => array('title' => t('Y'), 'class' => array('a', 'b', 'c', 'd'))).
- * $correct = drupal_array_merge_deep($link_options_1, $link_options_2);
+ * $correct = array_merge_deep($link_options_1, $link_options_2);
  * @endcode
  *
  * @param ...
@@ -2053,30 +2054,30 @@ function drupal_hash_base64($data) {
  * @return
  *   The merged array.
  *
- * @see drupal_array_merge_deep_array()
+ * @see array_merge_deep_array()
  */
-function drupal_array_merge_deep() {
-  return drupal_array_merge_deep_array(func_get_args());
+function array_merge_deep() {
+  return array_merge_deep_array(func_get_args());
 }
 
 /**
  * Merges multiple arrays, recursively, and returns the merged array.
  *
- * This function is equivalent to drupal_array_merge_deep(), except the
+ * This function is equivalent to array_merge_deep(), except the
  * input arrays are passed as a single array parameter rather than a variable
  * parameter list.
  *
  * The following are equivalent:
- * - drupal_array_merge_deep($a, $b);
- * - drupal_array_merge_deep_array(array($a, $b));
+ * - array_merge_deep($a, $b);
+ * - array_merge_deep_array(array($a, $b));
  *
  * The following are also equivalent:
- * - call_user_func_array('drupal_array_merge_deep', $arrays_to_merge);
- * - drupal_array_merge_deep_array($arrays_to_merge);
+ * - call_user_func_array('array_merge_deep', $arrays_to_merge);
+ * - array_merge_deep_array($arrays_to_merge);
  *
- * @see drupal_array_merge_deep()
+ * @see array_merge_deep()
  */
-function drupal_array_merge_deep_array($arrays) {
+function array_merge_deep_array($arrays) {
   $result = array();
 
   foreach ($arrays as $array) {
@@ -2089,7 +2090,7 @@ function drupal_array_merge_deep_array($arrays) {
       }
       // Recurse when both values are arrays.
       elseif (isset($result[$key]) && is_array($result[$key]) && is_array($value)) {
-        $result[$key] = drupal_array_merge_deep_array(array($result[$key], $value));
+        $result[$key] = array_merge_deep_array(array($result[$key], $value));
       }
       // Otherwise, use the latter value, overriding any previous value.
       else {
@@ -2106,12 +2107,12 @@ function drupal_array_merge_deep_array($arrays) {
  *
  * @return Object - the user object.
  */
-function drupal_anonymous_user() {
+function anonymous_user() {
   $user = new stdClass();
   $user->uid = 0;
   $user->hostname = ip_address();
   $user->roles = array();
-  $user->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user';
+  $user->roles[ANONYMOUS_RID] = 'anonymous user';
   $user->cache = 0;
   return $user;
 }
@@ -2123,31 +2124,31 @@ function drupal_anonymous_user() {
  * to load. Each phase adds to the previous one, so invoking a later phase
  * automatically runs the earlier phases as well. To access the Drupal
  * database from a script without loading anything else, include bootstrap.inc
- * and call drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE).
+ * and call bootstrap(BOOTSTRAP_DATABASE).
  *
  * @param $phase
  *   A constant. Allowed values are the DRUPAL_BOOTSTRAP_* constants.
  * @param $new_phase
- *   A boolean, set to FALSE if calling drupal_bootstrap from inside a
- *   function called from drupal_bootstrap (recursion).
+ *   A boolean, set to FALSE if calling bootstrap from inside a
+ *   function called from bootstrap (recursion).
  *
  * @return
  *   The most recently completed phase.
  */
-function drupal_bootstrap($phase = NULL, $new_phase = TRUE) {
+function bootstrap($phase = NULL, $new_phase = TRUE) {
   // Not drupal_static(), because does not depend on any run-time information.
   static $phases = array(
-    DRUPAL_BOOTSTRAP_CONFIGURATION,
-    DRUPAL_BOOTSTRAP_PAGE_CACHE,
-    DRUPAL_BOOTSTRAP_DATABASE,
-    DRUPAL_BOOTSTRAP_VARIABLES,
-    DRUPAL_BOOTSTRAP_SESSION,
-    DRUPAL_BOOTSTRAP_PAGE_HEADER,
-    DRUPAL_BOOTSTRAP_LANGUAGE,
-    DRUPAL_BOOTSTRAP_FULL,
+    BOOTSTRAP_CONFIGURATION,
+    BOOTSTRAP_PAGE_CACHE,
+    BOOTSTRAP_DATABASE,
+    BOOTSTRAP_VARIABLES,
+    BOOTSTRAP_SESSION,
+    BOOTSTRAP_PAGE_HEADER,
+    BOOTSTRAP_LANGUAGE,
+    BOOTSTRAP_FULL,
   );
   // Not drupal_static(), because the only legitimate API to control this is to
-  // call drupal_bootstrap() with a new phase parameter.
+  // call bootstrap() with a new phase parameter.
   static $final_phase;
   // Not drupal_static(), because it's impossible to roll back to an earlier
   // bootstrap state.
@@ -2171,38 +2172,38 @@ function drupal_bootstrap($phase = NULL, $new_phase = TRUE) {
       }
 
       switch ($current_phase) {
-        case DRUPAL_BOOTSTRAP_CONFIGURATION:
-          _drupal_bootstrap_configuration();
+        case BOOTSTRAP_CONFIGURATION:
+          _bootstrap_configuration();
           break;
 
-        case DRUPAL_BOOTSTRAP_PAGE_CACHE:
-          _drupal_bootstrap_page_cache();
+        case BOOTSTRAP_PAGE_CACHE:
+          _bootstrap_page_cache();
           break;
 
-        case DRUPAL_BOOTSTRAP_DATABASE:
-          _drupal_bootstrap_database();
+        case BOOTSTRAP_DATABASE:
+          _bootstrap_database();
           break;
 
-        case DRUPAL_BOOTSTRAP_VARIABLES:
-          _drupal_bootstrap_variables();
+        case BOOTSTRAP_VARIABLES:
+          _bootstrap_variables();
           break;
 
-        case DRUPAL_BOOTSTRAP_SESSION:
-          require_once DRUPAL_ROOT . '/' . variable_get('session_inc', 'core/includes/session.inc');
-          drupal_session_initialize();
+        case BOOTSTRAP_SESSION:
+          require_once ROOT . '/' . variable_get('session_inc', 'core/includes/session.inc');
+          session_initialize();
           break;
 
-        case DRUPAL_BOOTSTRAP_PAGE_HEADER:
-          _drupal_bootstrap_page_header();
+        case BOOTSTRAP_PAGE_HEADER:
+          _bootstrap_page_header();
           break;
 
-        case DRUPAL_BOOTSTRAP_LANGUAGE:
-          drupal_language_initialize();
+        case BOOTSTRAP_LANGUAGE:
+          language_initialize();
           break;
 
-        case DRUPAL_BOOTSTRAP_FULL:
-          require_once DRUPAL_ROOT . '/core/includes/common.inc';
-          _drupal_bootstrap_full();
+        case BOOTSTRAP_FULL:
+          require_once ROOT . '/core/includes/common.inc';
+          _bootstrap_full();
           break;
       }
     }
@@ -2213,7 +2214,7 @@ function drupal_bootstrap($phase = NULL, $new_phase = TRUE) {
 /**
  * Returns the time zone of the current user.
  */
-function drupal_get_user_timezone() {
+function get_user_timezone() {
   global $user;
   if (variable_get('configurable_timezones', 1) && $user->uid && $user->timezone) {
     return $user->timezone;
@@ -2240,9 +2241,9 @@ function drupal_get_user_timezone() {
  *   An array that points to the active symbol table at the point the error
  *   occurred.
  */
-function _drupal_error_handler($error_level, $message, $filename, $line, $context) {
-  require_once DRUPAL_ROOT . '/core/includes/errors.inc';
-  _drupal_error_handler_real($error_level, $message, $filename, $line, $context);
+function _error_handler($error_level, $message, $filename, $line, $context) {
+  require_once ROOT . '/core/includes/errors.inc';
+  _error_handler_real($error_level, $message, $filename, $line, $context);
 }
 
 /**
@@ -2255,20 +2256,20 @@ function _drupal_error_handler($error_level, $message, $filename, $line, $contex
  * @param $exception
  *   The exception object that was thrown.
  */
-function _drupal_exception_handler($exception) {
-  require_once DRUPAL_ROOT . '/core/includes/errors.inc';
+function _exception_handler($exception) {
+  require_once ROOT . '/core/includes/errors.inc';
 
   try {
     // Log the message to the watchdog and return an error page to the user.
-    _drupal_log_error(_drupal_decode_exception($exception), TRUE);
+    _log_error(_decode_exception($exception), TRUE);
   }
   catch (Exception $exception2) {
     // Another uncaught exception was thrown while handling the first one.
     // If we are displaying errors, then do so with no possibility of a further uncaught exception being thrown.
     if (error_displayable()) {
       print '<h1>Additional uncaught exception thrown while handling exception.</h1>';
-      print '<h2>Original</h2><p>' . _drupal_render_exception_safe($exception) . '</p>';
-      print '<h2>Additional</h2><p>' . _drupal_render_exception_safe($exception2) . '</p><hr />';
+      print '<h2>Original</h2><p>' . _render_exception_safe($exception) . '</p>';
+      print '<h2>Additional</h2><p>' . _render_exception_safe($exception2) . '</p><hr />';
     }
   }
 }
@@ -2276,24 +2277,25 @@ function _drupal_exception_handler($exception) {
 /**
  * Sets up the script environment and loads settings.php.
  */
-function _drupal_bootstrap_configuration() {
+function _bootstrap_configuration() {
+  global $hash_salt;
   // Set the Drupal custom error handler.
-  set_error_handler('_drupal_error_handler');
-  set_exception_handler('_drupal_exception_handler');
+  set_error_handler('Drupal\_error_handler');
+  set_exception_handler('Drupal\_exception_handler');
 
-  drupal_environment_initialize();
+  environment_initialize();
   // Start a page timer:
   timer_start('page');
   // Initialize the configuration, including variables from settings.php.
-  drupal_settings_initialize();
+  settings_initialize();
 
   // Include and activate the class loader.
-  $loader = drupal_classloader();
+  $loader = classloader();
 
   // Register explicit vendor namespaces.
   $loader->registerNamespaces(array(
     // All Symfony-borrowed code lives in /core/includes/Symfony.
-    'Symfony' => DRUPAL_ROOT . '/core/includes',
+    'Symfony' => ROOT . '/core/includes',
   ));
   // Register the Drupal namespace for classes in core as a fallback.
   // This allows to register additional namespaces within the Drupal namespace
@@ -2303,52 +2305,52 @@ function _drupal_bootstrap_configuration() {
   // register/overload namespaces in Drupal core.
   $loader->registerNamespaceFallbacks(array(
     // All Drupal-namespaced code in core lives in /core/includes/Drupal.
-    'Drupal' => DRUPAL_ROOT . '/core/includes',
+    'Drupal' => ROOT . '/core/includes',
   ));
 }
 
 /**
  * Attempts to serve a page from the cache.
  */
-function _drupal_bootstrap_page_cache() {
+function _bootstrap_page_cache() {
   global $user;
 
   // Allow specifying special cache handlers in settings.php, like
   // using memcached or files for storing cache information.
-  require_once DRUPAL_ROOT . '/core/includes/cache.inc';
+  require_once ROOT . '/core/includes/cache.inc';
   foreach (variable_get('cache_backends', array()) as $include) {
-    require_once DRUPAL_ROOT . '/' . $include;
+    require_once ROOT . '/' . $include;
   }
   // Check for a cache mode force from settings.php.
   if (variable_get('page_cache_without_database')) {
     $cache_enabled = TRUE;
   }
   else {
-    drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES, FALSE);
+    bootstrap(BOOTSTRAP_VARIABLES, FALSE);
     $cache_enabled = variable_get('cache');
   }
-  drupal_block_denied(ip_address());
+  block_denied(ip_address());
   // If there is no session cookie and cache is enabled (or forced), try
   // to serve a cached page.
   if (!isset($_COOKIE[session_name()]) && $cache_enabled) {
     // Make sure there is a user object because its timestamp will be
     // checked, hook_boot might check for anonymous user etc.
-    $user = drupal_anonymous_user();
+    $user = anonymous_user();
     // Get the page from the cache.
-    $cache = drupal_page_get_cache();
+    $cache = page_get_cache();
     // If there is a cached page, display it.
     if (is_object($cache)) {
       header('X-Drupal-Cache: HIT');
       // Restore the metadata cached with the page.
       $_GET['q'] = $cache->data['path'];
-      drupal_set_title($cache->data['title'], PASS_THROUGH);
-      date_default_timezone_set(drupal_get_user_timezone());
+      set_title($cache->data['title'], PASS_THROUGH);
+      date_default_timezone_set(get_user_timezone());
       // If the skipping of the bootstrap hooks is not enforced, call
       // hook_boot.
       if (variable_get('page_cache_invoke_hooks', TRUE)) {
         bootstrap_invoke_all('boot');
       }
-      drupal_serve_page_from_cache($cache);
+      serve_page_from_cache($cache);
       // If the skipping of the bootstrap hooks is not enforced, call
       // hook_exit.
       if (variable_get('page_cache_invoke_hooks', TRUE)) {
@@ -2366,21 +2368,21 @@ function _drupal_bootstrap_page_cache() {
 /**
  * Initializes the database system and registers autoload functions.
  */
-function _drupal_bootstrap_database() {
+function _bootstrap_database() {
   // Redirect the user to the installation script if Drupal has not been
   // installed yet (i.e., if no $databases array has been defined in the
   // settings.php file) and we are not already installing.
-  if (empty($GLOBALS['databases']) && !drupal_installation_attempted()) {
-    include_once DRUPAL_ROOT . '/core/includes/install.inc';
-    install_goto('core/install.php');
+  if (empty($GLOBALS['databases']) && !installation_attempted()) {
+    include_once ROOT . '/core/includes/install.inc';
+    install_redirect('core/install.php');
   }
 
   // The user agent header is used to pass a database prefix in the request when
   // running tests. However, for security reasons, it is imperative that we
   // validate we ourselves made the request.
-  if ($test_prefix = drupal_valid_test_ua()) {
+  if ($test_prefix = valid_test_ua()) {
     // Set the test run id for use in other parts of Drupal.
-    $test_info = &$GLOBALS['drupal_test_info'];
+    $test_info = &$GLOBALS['test_info'];
     $test_info['test_run_id'] = $test_prefix;
     $test_info['in_child_site'] = TRUE;
 
@@ -2405,54 +2407,54 @@ function _drupal_bootstrap_database() {
 
   // Initialize the database system. Note that the connection
   // won't be initialized until it is actually requested.
-  require_once DRUPAL_ROOT . '/core/includes/database/database.inc';
+  require_once ROOT . '/core/includes/database/database.inc';
 
   // Register autoload functions so that we can access classes and interfaces.
   // The database autoload routine comes first so that we can load the database
   // system without hitting the database. That is especially important during
   // the install or upgrade process.
-  spl_autoload_register('drupal_autoload_class');
-  spl_autoload_register('drupal_autoload_interface');
+  spl_autoload_register('Drupal\autoload_class');
+  spl_autoload_register('Drupal\autoload_interface');
 }
 
 /**
  * Loads system variables and all enabled bootstrap modules.
  */
-function _drupal_bootstrap_variables() {
+function _bootstrap_variables() {
   global $conf;
 
   // Initialize the lock system.
-  require_once DRUPAL_ROOT . '/' . variable_get('lock_inc', 'core/includes/lock.inc');
+  require_once ROOT . '/' . variable_get('lock_inc', 'core/includes/lock.inc');
   lock_initialize();
 
   // Load variables from the database, but do not overwrite variables set in settings.php.
   $conf = variable_initialize(isset($conf) ? $conf : array());
   // Load bootstrap modules.
-  require_once DRUPAL_ROOT . '/core/includes/module.inc';
+  require_once ROOT . '/core/includes/module.inc';
   module_load_all(TRUE);
 }
 
 /**
  * Invokes hook_boot(), initializes locking system, and sends HTTP headers.
  */
-function _drupal_bootstrap_page_header() {
+function _bootstrap_page_header() {
   bootstrap_invoke_all('boot');
 
-  if (!drupal_is_cli()) {
+  if (!is_cli()) {
     ob_start();
-    drupal_page_header();
+    page_header();
   }
 }
 
 /**
  * Returns the current bootstrap phase for this Drupal process.
  *
- * The current phase is the one most recently completed by drupal_bootstrap().
+ * The current phase is the one most recently completed by bootstrap().
  *
- * @see drupal_bootstrap()
+ * @see bootstrap()
  */
-function drupal_get_bootstrap_phase() {
-  return drupal_bootstrap();
+function get_bootstrap_phase() {
+  return bootstrap();
 }
 
 /**
@@ -2463,8 +2465,8 @@ function drupal_get_bootstrap_phase() {
  *   number of digits) or FALSE if the user agent does not contain a valid
  *   HMAC and timestamp.
  */
-function drupal_valid_test_ua() {
-  global $drupal_hash_salt;
+function valid_test_ua() {
+  global $hash_salt;
   // No reason to reset this.
   static $test_prefix;
 
@@ -2478,11 +2480,11 @@ function drupal_valid_test_ua() {
     // We use the salt from settings.php to make the HMAC key, since
     // the database is not yet initialized and we can't access any Drupal variables.
     // The file properties add more entropy not easily accessible to others.
-    $key = $drupal_hash_salt . filectime(__FILE__) . fileinode(__FILE__);
+    $key = $hash_salt . filectime(__FILE__) . fileinode(__FILE__);
     $time_diff = REQUEST_TIME - $time;
     // Since we are making a local request a 5 second time window is allowed,
     // and the HMAC must match.
-    if ($time_diff >= 0 && $time_diff <= 5 && $hmac == drupal_hmac_base64($check_string, $key)) {
+    if ($time_diff >= 0 && $time_diff <= 5 && $hmac == hmac_base64($check_string, $key)) {
       $test_prefix = $prefix;
       return $test_prefix;
     }
@@ -2494,20 +2496,20 @@ function drupal_valid_test_ua() {
 /**
  * Generates a user agent string with a HMAC and timestamp for simpletest.
  */
-function drupal_generate_test_ua($prefix) {
-  global $drupal_hash_salt;
+function generate_test_ua($prefix) {
+  global $hash_salt;
   static $key;
 
   if (!isset($key)) {
     // We use the salt from settings.php to make the HMAC key, since
     // the database is not yet initialized and we can't access any Drupal variables.
     // The file properties add more entropy not easily accessible to others.
-    $key = $drupal_hash_salt . filectime(__FILE__) . fileinode(__FILE__);
+    $key = $hash_salt . filectime(__FILE__) . fileinode(__FILE__);
   }
   // Generate a moderately secure HMAC based on the database credentials.
   $salt = uniqid('', TRUE);
   $check_string = $prefix . ';' . time() . ';' . $salt;
-  return $check_string . ';' . drupal_hmac_base64($check_string, $key);
+  return $check_string . ';' . hmac_base64($check_string, $key);
 }
 
 /**
@@ -2516,11 +2518,11 @@ function drupal_generate_test_ua($prefix) {
  * Loads and initializes the theme system for site installs, updates and when
  * the site is in maintenance mode. This also applies when the database fails.
  *
- * @see _drupal_maintenance_theme()
+ * @see _maintenance_theme()
  */
-function drupal_maintenance_theme() {
-  require_once DRUPAL_ROOT . '/core/includes/theme.maintenance.inc';
-  _drupal_maintenance_theme();
+function maintenance_theme() {
+  require_once ROOT . '/core/includes/theme.maintenance.inc';
+  _maintenance_theme();
 }
 
 /**
@@ -2529,7 +2531,7 @@ function drupal_maintenance_theme() {
  * If fast 404 pages are enabled, and this is a matching page then print a
  * simple 404 page and exit.
  *
- * This function is called from drupal_deliver_html_page() at the time when a
+ * This function is called from deliver_html_page() at the time when a
  * a normal 404 page is generated, but it can also optionally be called directly
  * from settings.php to prevent a Drupal bootstrap on these pages. See
  * documentation in settings.php for the benefits and drawbacks of using this.
@@ -2537,12 +2539,12 @@ function drupal_maintenance_theme() {
  * Paths to dynamically-generated content, such as image styles, should also be
  * accounted for in this function.
  */
-function drupal_fast_404() {
+function fast_404() {
   $exclude_paths = variable_get('404_fast_paths_exclude', FALSE);
   if ($exclude_paths && !preg_match($exclude_paths, $_GET['q'])) {
     $fast_paths = variable_get('404_fast_paths', FALSE);
     if ($fast_paths && preg_match($fast_paths, $_GET['q'])) {
-      drupal_add_http_header('Status', '404 Not Found');
+      add_http_header('Status', '404 Not Found');
       $fast_404_html = variable_get('404_fast_html', '<html xmlns="http://www.w3.org/1999/xhtml"><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>');
       // Replace @path in the variable with the page path.
       print strtr($fast_404_html, array('@path' => check_plain(request_uri())));
@@ -2554,7 +2556,7 @@ function drupal_fast_404() {
 /**
  * Returns TRUE if a Drupal installation is currently being attempted.
  */
-function drupal_installation_attempted() {
+function installation_attempted() {
   return defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install';
 }
 
@@ -2589,7 +2591,7 @@ function get_t() {
   // This is not converted to drupal_static because there is no point in
   // resetting this as it can not change in the course of a request.
   if (!isset($t)) {
-    $t = drupal_installation_attempted() ? 'st' : 't';
+    $t = installation_attempted() ? 'Drupal\st' : 'Drupal\t';
   }
   return $t;
 }
@@ -2597,7 +2599,7 @@ function get_t() {
 /**
  * Initializes all the defined language types.
  */
-function drupal_language_initialize() {
+function language_initialize() {
   $types = language_types();
 
   // Ensure the language is correctly returned, even without multilanguage
@@ -2609,9 +2611,9 @@ function drupal_language_initialize() {
     $GLOBALS[$type] = $default;
   }
   if (language_multilingual()) {
-    include_once DRUPAL_ROOT . '/core/includes/language.inc';
+    include_once ROOT . '/core/includes/language.inc';
     foreach ($types as $type) {
-      $GLOBALS[$type] = language_initialize($type);
+      $GLOBALS[$type] = _language_initialize($type);
     }
     // Allow modules to react on language system initialization in multilingual
     // environments.
@@ -2626,7 +2628,7 @@ function drupal_language_initialize() {
  *   An array of key-values pairs where the key is the language type and the
  *   value is its configurability.
  */
-function drupal_language_types() {
+function _language_types() {
   return array(
     LANGUAGE_TYPE_INTERFACE => TRUE,
     LANGUAGE_TYPE_CONTENT => FALSE,
@@ -2648,7 +2650,7 @@ function language_multilingual() {
  * Returns an array of the available language types.
  */
 function language_types() {
-  return array_keys(variable_get('language_types', drupal_language_types()));
+  return array_keys(variable_get('language_types', _language_types()));
 }
 
 /**
@@ -2740,7 +2742,7 @@ function request_path() {
 
   if (isset($_GET['q'])) {
     // This is a request with a ?q=foo/bar query string. $_GET['q'] is
-    // overwritten in drupal_path_initialize(), but request_path() is called
+    // overwritten in path_initialize(), but request_path() is called
     // very early in the bootstrap process, so the original value is saved in
     // $path and returned in later calls.
     $path = $_GET['q'];
@@ -2802,11 +2804,11 @@ function arg($index = NULL, $path = NULL) {
   // information), it should be resettable anyway in case a module needs to
   // free up the memory used by it.
   // Use the advanced drupal_static() pattern, since this is called very often.
-  static $drupal_static_fast;
-  if (!isset($drupal_static_fast)) {
-    $drupal_static_fast['arguments'] = &drupal_static(__FUNCTION__);
+  static $static_fast;
+  if (!isset($static_fast)) {
+    $static_fast['arguments'] = &drupal_static(__FUNCTION__);
   }
-  $arguments = &$drupal_static_fast['arguments'];
+  $arguments = &$static_fast['arguments'];
 
   if (!isset($path)) {
     $path = $_GET['q'];
@@ -2884,11 +2886,11 @@ function ip_address() {
  * @param $rebuild
  *   If true, the schema will be rebuilt instead of retrieved from the cache.
  */
-function drupal_get_schema($table = NULL, $rebuild = FALSE) {
+function get_schema($table = NULL, $rebuild = FALSE) {
   static $schema;
 
   if ($rebuild || !isset($table)) {
-    $schema = drupal_get_complete_schema($rebuild);
+    $schema = get_complete_schema($rebuild);
   }
   elseif (!isset($schema)) {
     $schema = new SchemaCache();
@@ -2906,9 +2908,9 @@ function drupal_get_schema($table = NULL, $rebuild = FALSE) {
 }
 
 /**
- * Extends DrupalCacheArray to allow for dynamic building of the schema cache.
+ * Extends CacheArray to allow for dynamic building of the schema cache.
  */
-class SchemaCache extends DrupalCacheArray {
+class SchemaCache extends CacheArray {
 
   /**
    * Constructs a SchemaCache object.
@@ -2919,10 +2921,10 @@ class SchemaCache extends DrupalCacheArray {
   }
 
   /**
-   * Overrides DrupalCacheArray::resolveCacheMiss().
+   * Overrides CacheArray::resolveCacheMiss().
    */
   protected function resolveCacheMiss($offset) {
-    $complete_schema = drupal_get_complete_schema();
+    $complete_schema = get_complete_schema();
     $value = isset($complete_schema[$offset]) ? $complete_schema[$offset] :  NULL;
     $this->storage[$offset] = $value;
     $this->persist($offset);
@@ -2939,7 +2941,7 @@ class SchemaCache extends DrupalCacheArray {
  * @param $rebuild
  *   If true, the schema will be rebuilt instead of retrieved from the cache.
  */
-function drupal_get_complete_schema($rebuild = FALSE) {
+function get_complete_schema($rebuild = FALSE) {
   static $schema = array();
 
   if (empty($schema) || $rebuild) {
@@ -2953,7 +2955,7 @@ function drupal_get_complete_schema($rebuild = FALSE) {
       // Load the .install files to get hook_schema.
       // On some databases this function may be called before bootstrap has
       // been completed, so we force the functions we need to load just in case.
-      if (function_exists('module_load_all_includes')) {
+      if (function_exists('Drupal\module_load_all_includes')) {
         // This function can be called very early in the bootstrap process, so
         // we force the module_list() cache to be refreshed to ensure that it
         // contains the complete list of modules before we go on to call
@@ -2962,7 +2964,7 @@ function drupal_get_complete_schema($rebuild = FALSE) {
         module_load_all_includes('install');
       }
 
-      require_once DRUPAL_ROOT . '/core/includes/common.inc';
+      require_once ROOT . '/core/includes/common.inc';
       // Invoke hook_schema for all modules.
       foreach (module_implements('schema') as $module) {
         // Cast the result of hook_schema() to an array, as a NULL return value
@@ -2971,14 +2973,14 @@ function drupal_get_complete_schema($rebuild = FALSE) {
         $current = (array) module_invoke($module, 'schema');
         // Set 'module' and 'name' keys for each table, and remove descriptions,
         // as they needlessly slow down cache()->get() for every single request.
-        _drupal_schema_initialize($current, $module);
+        _schema_initialize($current, $module);
         $schema = array_merge($schema, $current);
       }
 
-      drupal_alter('schema', $schema);
+      alter('schema', $schema);
       // If the schema is empty, avoid saving it: some database engines require
       // the schema to perform queries, and this could lead to infinite loops.
-      if (!empty($schema) && (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL)) {
+      if (!empty($schema) && (get_bootstrap_phase() == BOOTSTRAP_FULL)) {
         cache()->set('schema', $schema);
       }
       if ($rebuild) {
@@ -3005,15 +3007,15 @@ function drupal_get_complete_schema($rebuild = FALSE) {
  *
  * The class loader is responsible for lazy-loading all PSR-0 compatible
  * classes, interfaces, and traits (PHP 5.4 and later). Its only dependencies
- * are DRUPAL_ROOT and variable_get(). Otherwise it may be called as early as
+ * are ROOT and variable_get(). Otherwise it may be called as early as
  * possible.
  *
  * @return Symfony\Component\ClassLoader\UniversalClassLoader
  *   A UniversalClassLoader class instance (or extension thereof).
  */
-function drupal_classloader() {
+function classloader() {
   // Include the Symfony ClassLoader for loading PSR-0-compatible classes.
-  require_once DRUPAL_ROOT . '/core/includes/Symfony/Component/ClassLoader/UniversalClassLoader.php';
+  require_once ROOT . '/core/includes/Symfony/Component/ClassLoader/UniversalClassLoader.php';
 
   // By default, use the UniversalClassLoader which is best for development,
   // as it does not break when code is moved on the file system. However, as it
@@ -3025,8 +3027,8 @@ function drupal_classloader() {
     switch (variable_get('autoloader_mode', 'default')) {
       case 'apc':
         if (function_exists('apc_store')) {
-          require_once DRUPAL_ROOT . '/core/includes/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php';
-          $loader = new ApcUniversalClassLoader('drupal.' . $GLOBALS['drupal_hash_salt']);
+          require_once ROOT . '/core/includes/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php';
+          $loader = new ApcUniversalClassLoader('drupal.' . $GLOBALS['hash_salt']);
           break;
         }
       // Fall through to the default loader if APC was not loaded, so that the
@@ -3054,7 +3056,7 @@ function drupal_classloader() {
  * @return
  *   TRUE if the interface is currently available, FALSE otherwise.
  */
-function drupal_autoload_interface($interface) {
+function autoload_interface($interface) {
   return _registry_check_code('interface', $interface);
 }
 
@@ -3070,7 +3072,7 @@ function drupal_autoload_interface($interface) {
  * @return
  *   TRUE if the class is currently available, FALSE otherwise.
  */
-function drupal_autoload_class($class) {
+function autoload_class($class) {
   return _registry_check_code('class', $class);
 }
 
@@ -3092,6 +3094,11 @@ function drupal_autoload_class($class) {
 function _registry_check_code($type, $name = NULL) {
   static $lookup_cache, $cache_update_needed;
 
+  // We only deal with classes and interfaces prefixed with Drupal\.
+  if (($type == 'class' || $type == 'interface') && substr($name, 0, 7) != 'Drupal\\') {
+    return FALSE;
+  }
+
   if ($type == 'class' && class_exists($name) || $type == 'interface' && interface_exists($name)) {
     return TRUE;
   }
@@ -3111,7 +3118,7 @@ function _registry_check_code($type, $name = NULL) {
     return;
   }
 
-  // Called from drupal_page_footer, we write to permanent storage if there
+  // Called from page_footer, we write to permanent storage if there
   // changes to the lookup cache for this request.
   if ($type == REGISTRY_WRITE_LOOKUP_CACHE) {
     if ($cache_update_needed) {
@@ -3120,12 +3127,15 @@ function _registry_check_code($type, $name = NULL) {
     return;
   }
 
+  // Remove Drupal\ prefix.
+  $name = substr($name, 7);
+
   // $type is either 'interface' or 'class', so we only need the first letter to
   // keep the cache key unique.
   $cache_key = $type[0] . $name;
   if (isset($lookup_cache[$cache_key])) {
     if ($lookup_cache[$cache_key]) {
-      require_once DRUPAL_ROOT . '/' . $lookup_cache[$cache_key];
+      require_once ROOT . '/' . $lookup_cache[$cache_key];
     }
     return (bool) $lookup_cache[$cache_key];
   }
@@ -3147,7 +3157,7 @@ function _registry_check_code($type, $name = NULL) {
   $lookup_cache[$cache_key] = $file;
 
   if ($file) {
-    require_once DRUPAL_ROOT . '/' . $file;
+    require_once ROOT . '/' . $file;
     return TRUE;
   }
   else {
@@ -3176,7 +3186,7 @@ function registry_rebuild() {
  * @see registry_rebuild()
  */
 function registry_update() {
-  require_once DRUPAL_ROOT . '/core/includes/registry.inc';
+  require_once ROOT . '/core/includes/registry.inc';
   _registry_update();
 }
 
@@ -3218,7 +3228,7 @@ function registry_update() {
  * function examples_admin_overview() {
  *   // When building the content for the overview page, make sure to get
  *   // completely fresh information.
- *   drupal_static_reset('example_list');
+ *   drupal_static_reset('Drupal\example_list');
  *   ...
  * }
  * @endcode
@@ -3274,11 +3284,11 @@ function registry_update() {
  * @code
  * function user_access($string, $account = NULL) {
  *   // Use the advanced drupal_static() pattern, since this is called very often.
- *   static $drupal_static_fast;
- *   if (!isset($drupal_static_fast)) {
- *     $drupal_static_fast['perm'] = &drupal_static(__FUNCTION__);
+ *   static $static_fast;
+ *   if (!isset($static_fast)) {
+ *     $static_fast['perm'] = &drupal_static(__FUNCTION__);
  *   }
- *   $perm = &$drupal_static_fast['perm'];
+ *   $perm = &$static_fast['perm'];
  *   ...
  * }
  * @endcode
@@ -3348,7 +3358,7 @@ function drupal_static_reset($name = NULL) {
 /**
  * Detects whether the current script is running in a command-line environment.
  */
-function drupal_is_cli() {
+function is_cli() {
   return (!isset($_SERVER['SERVER_SOFTWARE']) && (php_sapi_name() == 'cli' || (is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0)));
 }
 
@@ -3363,7 +3373,7 @@ function drupal_is_cli() {
  * @return
  *   The formatted text (html).
  */
-function drupal_placeholder($text) {
+function placeholder($text) {
   return '<em class="placeholder">' . check_plain($text) . '</em>';
 }
 
@@ -3392,7 +3402,7 @@ function &drupal_register_shutdown_function($callback = NULL) {
   if (isset($callback)) {
     // Only register the internal shutdown function once.
     if (empty($callbacks)) {
-      register_shutdown_function('_drupal_shutdown_function');
+      register_shutdown_function('Drupal\_shutdown_function');
     }
     $args = func_get_args();
     array_shift($args);
@@ -3405,12 +3415,12 @@ function &drupal_register_shutdown_function($callback = NULL) {
 /**
  * Executes registered shutdown functions.
  */
-function _drupal_shutdown_function() {
+function _shutdown_function() {
   $callbacks = &drupal_register_shutdown_function();
 
-  // Set the CWD to DRUPAL_ROOT as it is not guaranteed to be the same as it
+  // Set the CWD to ROOT as it is not guaranteed to be the same as it
   // was in the normal context of execution.
-  chdir(DRUPAL_ROOT);
+  chdir(ROOT);
 
   try {
     while (list($key, $callback) = each($callbacks)) {
@@ -3419,10 +3429,10 @@ function _drupal_shutdown_function() {
   }
   catch (Exception $exception) {
     // If we are displaying errors, then do so with no possibility of a further uncaught exception being thrown.
-   require_once DRUPAL_ROOT . '/core/includes/errors.inc';
+   require_once ROOT . '/core/includes/errors.inc';
    if (error_displayable()) {
       print '<h1>Uncaught exception thrown in shutdown function.</h1>';
-      print '<p>' . _drupal_render_exception_safe($exception) . '</p><hr />';
+      print '<p>' . _render_exception_safe($exception) . '</p><hr />';
     }
   }
 }
diff --git a/core/includes/cache.inc b/core/includes/cache.inc
index 48dbdd3..35bba00 100644
--- a/core/includes/cache.inc
+++ b/core/includes/cache.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
diff --git a/core/includes/common.inc b/core/includes/common.inc
index 67a4457..9b71c8c 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, PDO, stdClass;
 
 /**
  * @file
@@ -92,7 +94,7 @@ const JS_SETTING = 200;
 /**
  * Error code indicating that the request exceeded the specified timeout.
  *
- * @see drupal_http_request()
+ * @see http_request()
  */
 const HTTP_REQUEST_TIMEOUT = -1;
 
@@ -101,15 +103,15 @@ const HTTP_REQUEST_TIMEOUT = -1;
  *
  * Modules specify the caching patterns for their blocks using binary
  * combinations of these constants in their hook_block_info():
- *   $block[delta]['cache'] = DRUPAL_CACHE_PER_ROLE | DRUPAL_CACHE_PER_PAGE;
- * DRUPAL_CACHE_PER_ROLE is used as a default when no caching pattern is
- * specified. Use DRUPAL_CACHE_CUSTOM to disable standard block cache and
+ *   $block[delta]['cache'] = CACHE_PER_ROLE | CACHE_PER_PAGE;
+ * CACHE_PER_ROLE is used as a default when no caching pattern is
+ * specified. Use CACHE_CUSTOM to disable standard block cache and
  * implement
  *
  * The block cache is cleared in cache_clear_all(), and uses the same clearing
  * policy than page cache (node, comment, user, taxonomy added or updated...).
  * Blocks requiring more fine-grained clearing might consider disabling the
- * built-in block cache (DRUPAL_NO_CACHE) and roll their own.
+ * built-in block cache (NO_CACHE) and roll their own.
  *
  * Note that user 1 is excluded from block caching.
  */
@@ -123,16 +125,16 @@ const HTTP_REQUEST_TIMEOUT = -1;
  *   content.
  * - For blocks that change too frequently.
  */
-const DRUPAL_NO_CACHE = -1;
+const NO_CACHE = -1;
 
 /**
  * The block is handling its own caching in its hook_block_view().
  *
  * From the perspective of the block cache system, this is equivalent to
- * DRUPAL_NO_CACHE. Useful when time based expiration is needed or a site uses
+ * NO_CACHE. Useful when time based expiration is needed or a site uses
  * a node access which invalidates standard block cache.
  */
-const DRUPAL_CACHE_CUSTOM = -2;
+const CACHE_CUSTOM = -2;
 
 /**
  * The block or element can change depending on the user's roles.
@@ -140,25 +142,25 @@ const DRUPAL_CACHE_CUSTOM = -2;
  * This is the default setting for blocks, used when the block does not specify
  * anything.
  */
-const DRUPAL_CACHE_PER_ROLE = 0x0001;
+const CACHE_PER_ROLE = 0x0001;
 
 /**
  * The block or element can change depending on the user.
  *
  * This setting can be resource-consuming for sites with large number of users,
- * and thus should only be used when DRUPAL_CACHE_PER_ROLE is not sufficient.
+ * and thus should only be used when CACHE_PER_ROLE is not sufficient.
  */
-const DRUPAL_CACHE_PER_USER = 0x0002;
+const CACHE_PER_USER = 0x0002;
 
 /**
  * The block or element can change depending on the page being viewed.
  */
-const DRUPAL_CACHE_PER_PAGE = 0x0004;
+const CACHE_PER_PAGE = 0x0004;
 
 /**
  * The block or element is the same for every user and page that it is visible.
  */
-const DRUPAL_CACHE_GLOBAL = 0x0008;
+const CACHE_GLOBAL = 0x0008;
 
 /**
  * Adds content to a specified region.
@@ -168,7 +170,7 @@ const DRUPAL_CACHE_GLOBAL = 0x0008;
  * @param $data
  *   Content to be added.
  */
-function drupal_add_region_content($region = NULL, $data = NULL) {
+function add_region_content($region = NULL, $data = NULL) {
   static $content = array();
 
   if (isset($region) && isset($data)) {
@@ -186,8 +188,8 @@ function drupal_add_region_content($region = NULL, $data = NULL) {
  * @param $delimiter
  *   Content to be inserted between imploded array elements.
  */
-function drupal_get_region_content($region = NULL, $delimiter = ' ') {
-  $content = drupal_add_region_content();
+function get_region_content($region = NULL, $delimiter = ' ') {
+  $content = add_region_content();
   if (isset($region)) {
     if (isset($content[$region]) && is_array($content[$region])) {
       return implode($delimiter, $content[$region]);
@@ -215,7 +217,7 @@ function drupal_get_region_content($region = NULL, $delimiter = ' ') {
  * @return $profile
  *   The name of the install profile.
  */
-function drupal_get_profile() {
+function get_profile() {
   global $install_state;
 
   if (isset($install_state['parameters']['profile'])) {
@@ -236,7 +238,7 @@ function drupal_get_profile() {
  *   Array of links, starting with "home" and proceeding up to but not including
  *   the current page.
  */
-function drupal_set_breadcrumb($breadcrumb = NULL) {
+function set_breadcrumb($breadcrumb = NULL) {
   $stored_breadcrumb = &drupal_static(__FUNCTION__);
 
   if (isset($breadcrumb)) {
@@ -248,8 +250,8 @@ function drupal_set_breadcrumb($breadcrumb = NULL) {
 /**
  * Gets the breadcrumb trail for the current page.
  */
-function drupal_get_breadcrumb() {
-  $breadcrumb = drupal_set_breadcrumb();
+function get_breadcrumb() {
+  $breadcrumb = set_breadcrumb();
 
   if (!isset($breadcrumb)) {
     $breadcrumb = menu_get_active_breadcrumb();
@@ -276,12 +278,12 @@ function drupal_get_breadcrumb() {
  *
  * @see theme_html_tag()
  */
-function drupal_add_html_head($data = NULL, $key = NULL) {
+function add_html_head($data = NULL, $key = NULL) {
   $stored_head = &drupal_static(__FUNCTION__);
 
   if (!isset($stored_head)) {
     // Make sure the defaults, including Content-Type, come first.
-    $stored_head = _drupal_default_html_head();
+    $stored_head = _default_html_head();
   }
 
   if (isset($data) && isset($key)) {
@@ -296,7 +298,7 @@ function drupal_add_html_head($data = NULL, $key = NULL) {
 /**
  * Returns elements that are always displayed in the HEAD tag of the HTML page.
  */
-function _drupal_default_html_head() {
+function _default_html_head() {
   // Add default elements. Make sure the Content-Type comes first because the
   // IE browser may be vulnerable to XSS via encoding attacks from any content
   // that comes before this META tag, such as a TITLE tag.
@@ -321,16 +323,16 @@ function _drupal_default_html_head() {
     ),
   );
   // Also send the generator in the HTTP header.
-  $elements['system_meta_generator']['#attached']['drupal_add_http_header'][] = array('X-Generator', $elements['system_meta_generator']['#attributes']['content']);
+  $elements['system_meta_generator']['#attached']['add_http_header'][] = array('X-Generator', $elements['system_meta_generator']['#attributes']['content']);
   return $elements;
 }
 
 /**
  * Retrieves output to be displayed in the HEAD tag of the HTML page.
  */
-function drupal_get_html_head() {
-  $elements = drupal_add_html_head();
-  drupal_alter('html_head', $elements);
+function get_html_head() {
+  $elements = add_html_head();
+  alter('html_head', $elements);
   return drupal_render($elements);
 }
 
@@ -344,13 +346,13 @@ function drupal_get_html_head() {
  * @param $title
  *   The title of the feed.
  */
-function drupal_add_feed($url = NULL, $title = '') {
+function add_feed($url = NULL, $title = '') {
   $stored_feed_links = &drupal_static(__FUNCTION__, array());
 
   if (isset($url)) {
     $stored_feed_links[$url] = theme('feed_icon', array('url' => $url, 'title' => $title));
 
-    drupal_add_html_head_link(array(
+    add_html_head_link(array(
       'rel' => 'alternate',
       'type' => 'application/rss+xml',
       'title' => $title,
@@ -368,8 +370,8 @@ function drupal_add_feed($url = NULL, $title = '') {
  * @param $delimiter
  *   A delimiter to split feeds by.
  */
-function drupal_get_feeds($delimiter = "\n") {
-  $feeds = drupal_add_feed();
+function get_feeds($delimiter = "\n") {
+  $feeds = add_feed();
   return implode($feeds, $delimiter);
 }
 
@@ -393,7 +395,7 @@ function drupal_get_feeds($delimiter = "\n") {
  * @return
  *   An array containing query parameters, which can be used for url().
  */
-function drupal_get_query_parameters(array $query = NULL, array $exclude = array('q'), $parent = '') {
+function get_query_parameters(array $query = NULL, array $exclude = array('q'), $parent = '') {
   // Set defaults, if none given.
   if (!isset($query)) {
     $query = $_GET;
@@ -414,7 +416,7 @@ function drupal_get_query_parameters(array $query = NULL, array $exclude = array
     }
 
     if (is_array($value)) {
-      $params[$key] = drupal_get_query_parameters($value, $exclude, $string_key);
+      $params[$key] = get_query_parameters($value, $exclude, $string_key);
     }
     else {
       $params[$key] = $value;
@@ -433,7 +435,7 @@ function drupal_get_query_parameters(array $query = NULL, array $exclude = array
  * @return
  *   An array of url decoded couples $param_name => $value.
  */
-function drupal_get_query_array($query) {
+function get_query_array($query) {
   $result = array();
   if (!empty($query)) {
     foreach (explode('&', $query) as $param) {
@@ -459,7 +461,7 @@ function drupal_get_query_array($query) {
  *   A rawurlencoded string which can be used as or appended to the URL query
  *   string.
  *
- * @see drupal_get_query_parameters()
+ * @see get_query_parameters()
  * @ingroup php_wrappers
  */
 function drupal_http_build_query(array $query, $parent = '') {
@@ -486,16 +488,16 @@ function drupal_http_build_query(array $query, $parent = '') {
 }
 
 /**
- * Prepares a 'destination' URL query parameter for use with drupal_goto().
+ * Prepares a 'destination' URL query parameter for use with redirect().
  *
  * Used to direct the user back to the referring page after completing a form.
  * By default the current URL is returned. If a destination exists in the
  * previous request, that destination is returned. As such, a destination can
  * persist across multiple pages.
  *
- * @see drupal_goto()
+ * @see redirect()
  */
-function drupal_get_destination() {
+function get_destination() {
   $destination = &drupal_static(__FUNCTION__);
 
   if (isset($destination)) {
@@ -507,7 +509,7 @@ function drupal_get_destination() {
   }
   else {
     $path = $_GET['q'];
-    $query = drupal_http_build_query(drupal_get_query_parameters());
+    $query = drupal_http_build_query(get_query_parameters());
     if ($query != '') {
       $path .= '?' . $query;
     }
@@ -547,7 +549,7 @@ function drupal_get_destination() {
  *   - 'fragment': The fragment of $url, if existent.
  *
  * @see url()
- * @see drupal_goto()
+ * @see redirect()
  * @ingroup php_wrappers
  */
 function drupal_parse_url($url) {
@@ -609,7 +611,7 @@ function drupal_parse_url($url) {
  * @param $path
  *   The Drupal path to encode.
  */
-function drupal_encode_path($path) {
+function encode_path($path) {
   return str_replace('%2F', '/', rawurlencode($path));
 }
 
@@ -629,7 +631,7 @@ function drupal_encode_path($path) {
  *   $link = l(t('Log in'), 'user/login', array('query' => $query));
  * @endcode
  *
- * Drupal will ensure that messages set by drupal_set_message() and other
+ * Drupal will ensure that messages set by set_message() and other
  * session data are written to the database before the user is redirected.
  *
  * This function ends the request; use it instead of a return in your menu
@@ -640,7 +642,7 @@ function drupal_encode_path($path) {
  * @param $options
  *   An associative array of additional URL options to pass to url().
  * @param $http_response_code
- *   Valid values for an actual "goto" as per RFC 2616 section 10.3 are:
+ *   Valid values for an actual "redirect" as per RFC 2616 section 10.3 are:
  *   - 301 Moved Permanently (the recommended value for most redirects)
  *   - 302 Found (default in Drupal and PHP, sometimes used for spamming search
  *         engines)
@@ -651,10 +653,10 @@ function drupal_encode_path($path) {
  *   Note: Other values are defined by RFC 2616, but are rarely used and poorly
  *   supported.
  *
- * @see drupal_get_destination()
+ * @see get_destination()
  * @see url()
  */
-function drupal_goto($path = '', array $options = array(), $http_response_code = 302) {
+function redirect($path = '', array $options = array(), $http_response_code = 302) {
   // A destination in $_GET always overrides the function arguments.
   // We do not allow absolute URLs to be passed via $_GET, as this can be an attack vector.
   if (isset($_GET['destination']) && !url_is_external($_GET['destination'])) {
@@ -664,7 +666,7 @@ function drupal_goto($path = '', array $options = array(), $http_response_code =
     $options['fragment'] = $destination['fragment'];
   }
 
-  drupal_alter('drupal_goto', $path, $options, $http_response_code);
+  alter('redirect', $path, $options, $http_response_code);
 
   // The 'Location' HTTP header must be absolute.
   $options['absolute'] = TRUE;
@@ -675,7 +677,7 @@ function drupal_goto($path = '', array $options = array(), $http_response_code =
 
   // The "Location" header sends a redirect status code to the HTTP daemon. In
   // some cases this can be wrong, so we make sure none of the code below the
-  // drupal_goto() call gets executed upon redirection.
+  // redirect() call gets executed upon redirection.
   drupal_exit($url);
 }
 
@@ -683,37 +685,37 @@ function drupal_goto($path = '', array $options = array(), $http_response_code =
  * Delivers a "site is under maintenance" message to the browser.
  *
  * Page callback functions wanting to report a "site offline" message should
- * return MENU_SITE_OFFLINE instead of calling drupal_site_offline(). However,
+ * return MENU_SITE_OFFLINE instead of calling site_offline(). However,
  * functions that are invoked in contexts where that return value might not
- * bubble up to menu_execute_active_handler() should call drupal_site_offline().
+ * bubble up to menu_execute_active_handler() should call site_offline().
  */
-function drupal_site_offline() {
-  drupal_deliver_page(MENU_SITE_OFFLINE);
+function site_offline() {
+  deliver_page(MENU_SITE_OFFLINE);
 }
 
 /**
  * Delivers a "page not found" error to the browser.
  *
  * Page callback functions wanting to report a "page not found" message should
- * return MENU_NOT_FOUND instead of calling drupal_not_found(). However,
+ * return MENU_NOT_FOUND instead of calling not_found(). However,
  * functions that are invoked in contexts where that return value might not
- * bubble up to menu_execute_active_handler() should call drupal_not_found().
+ * bubble up to menu_execute_active_handler() should call not_found().
  */
-function drupal_not_found() {
-  drupal_deliver_page(MENU_NOT_FOUND);
+function not_found() {
+  deliver_page(MENU_NOT_FOUND);
 }
 
 /**
  * Delivers an "access denied" error to the browser.
  *
  * Page callback functions wanting to report an "access denied" message should
- * return MENU_ACCESS_DENIED instead of calling drupal_access_denied(). However,
+ * return MENU_ACCESS_DENIED instead of calling access_denied(). However,
  * functions that are invoked in contexts where that return value might not
  * bubble up to menu_execute_active_handler() should call
- * drupal_access_denied().
+ * access_denied().
  */
-function drupal_access_denied() {
-  drupal_deliver_page(MENU_ACCESS_DENIED);
+function access_denied() {
+  deliver_page(MENU_ACCESS_DENIED);
 }
 
 /**
@@ -755,7 +757,7 @@ function drupal_access_denied() {
  *     easy access the array keys are returned in lower case.
  *   - data: A string containing the response body that was received.
  */
-function drupal_http_request($url, array $options = array()) {
+function http_request($url, array $options = array()) {
   $result = new stdClass();
 
   // Parse the URL and make sure we can handle the schema.
@@ -828,7 +830,7 @@ function drupal_http_request($url, array $options = array()) {
     // server's ability to make outgoing HTTP requests the next time that
     // requirements checking is performed.
     // See system_requirements().
-    variable_set('drupal_http_request_fails', TRUE);
+    variable_set('http_request_fails', TRUE);
 
     return $result;
   }
@@ -864,9 +866,9 @@ function drupal_http_request($url, array $options = array()) {
   // user-agent is used to ensure that multiple testing sessions running at the
   // same time won't interfere with each other as they would if the database
   // prefix were stored statically in a file or database variable.
-  $test_info = &$GLOBALS['drupal_test_info'];
+  $test_info = &$GLOBALS['test_info'];
   if (!empty($test_info['test_run_id'])) {
-    $options['headers']['User-Agent'] = drupal_generate_test_ua($test_info['test_run_id']);
+    $options['headers']['User-Agent'] = generate_test_ua($test_info['test_run_id']);
   }
 
   $request = $options['method'] . ' ' . $path . " HTTP/1.0\r\n";
@@ -1001,7 +1003,7 @@ function drupal_http_request($url, array $options = array()) {
       elseif ($options['max_redirects']) {
         // Redirect to the new location.
         $options['max_redirects']--;
-        $result = drupal_http_request($location, $options);
+        $result = http_request($location, $options);
         $result->redirect_code = $code;
       }
       if (!isset($result->redirect_url)) {
@@ -1028,7 +1030,7 @@ function drupal_http_request($url, array $options = array()) {
  */
 function _fix_gpc_magic(&$item) {
   if (is_array($item)) {
-    array_walk($item, '_fix_gpc_magic');
+    array_walk($item, 'Drupal\_fix_gpc_magic');
   }
   else {
     $item = stripslashes($item);
@@ -1053,7 +1055,7 @@ function _fix_gpc_magic(&$item) {
 function _fix_gpc_magic_files(&$item, $key) {
   if ($key != 'tmp_name') {
     if (is_array($item)) {
-      array_walk($item, '_fix_gpc_magic_files');
+      array_walk($item, 'Drupal\_fix_gpc_magic_files');
     }
     else {
       $item = stripslashes($item);
@@ -1070,11 +1072,11 @@ function _fix_gpc_magic_files(&$item, $key) {
 function fix_gpc_magic() {
   static $fixed = FALSE;
   if (!$fixed && ini_get('magic_quotes_gpc')) {
-    array_walk($_GET, '_fix_gpc_magic');
-    array_walk($_POST, '_fix_gpc_magic');
-    array_walk($_COOKIE, '_fix_gpc_magic');
-    array_walk($_REQUEST, '_fix_gpc_magic');
-    array_walk($_FILES, '_fix_gpc_magic_files');
+    array_walk($_GET, 'Drupal\_fix_gpc_magic');
+    array_walk($_POST, 'Drupal\_fix_gpc_magic');
+    array_walk($_COOKIE, 'Drupal\_fix_gpc_magic');
+    array_walk($_REQUEST, 'Drupal\_fix_gpc_magic');
+    array_walk($_FILES, 'Drupal\_fix_gpc_magic_files');
   }
   $fixed = TRUE;
 }
@@ -1236,7 +1238,7 @@ function flood_is_allowed($name, $threshold, $window = 3600, $identifier = NULL)
  * to being output to an HTML attribute value. It is often called as part of
  * check_url() or filter_xss(), but those functions return an HTML-encoded
  * string, so this function can be called independently when the output needs to
- * be a plain-text string for passing to t(), l(), drupal_attributes(), or
+ * be a plain-text string for passing to t(), l(), attributes(), or
  * another function that will call check_plain() separately.
  *
  * @param $uri
@@ -1250,7 +1252,7 @@ function flood_is_allowed($name, $threshold, $window = 3600, $identifier = NULL)
  *
  * @see check_url()
  */
-function drupal_strip_dangerous_protocols($uri) {
+function strip_dangerous_protocols($uri) {
   static $allowed_protocols;
 
   if (!isset($allowed_protocols)) {
@@ -1290,15 +1292,15 @@ function drupal_strip_dangerous_protocols($uri) {
  * @return
  *   A URI stripped of dangerous protocols and encoded for output to an HTML
  *   attribute value. Because it is already encoded, it should not be set as a
- *   value within a $attributes array passed to drupal_attributes(), because
- *   drupal_attributes() expects those values to be plain-text strings. To pass
- *   a filtered URI to drupal_attributes(), call
- *   drupal_strip_dangerous_protocols() instead.
+ *   value within a $attributes array passed to attributes(), because
+ *   attributes() expects those values to be plain-text strings. To pass
+ *   a filtered URI to attributes(), call
+ *   strip_dangerous_protocols() instead.
  *
- * @see drupal_strip_dangerous_protocols()
+ * @see strip_dangerous_protocols()
  */
 function check_url($uri) {
-  return check_plain(drupal_strip_dangerous_protocols($uri));
+  return check_plain(strip_dangerous_protocols($uri));
 }
 
 /**
@@ -1338,13 +1340,13 @@ function filter_xss_admin($string) {
  *   An XSS safe version of $string, or an empty string if $string is not
  *   valid UTF-8.
  *
- * @see drupal_validate_utf8()
+ * @see validate_utf8()
  * @ingroup sanitization
  */
 function filter_xss($string, $allowed_tags = array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd')) {
   // Only operate on valid UTF-8 strings. This is necessary to prevent cross
   // site scripting issues on Internet Explorer 6.
-  if (!drupal_validate_utf8($string)) {
+  if (!validate_utf8($string)) {
     return '';
   }
   // Store the text format.
@@ -1373,7 +1375,7 @@ function filter_xss($string, $allowed_tags = array('a', 'em', 'strong', 'cite',
     <[^>]*(>|$)       # a string that starts with a <, up until the > or the end of the string
     |                 # or
     >                 # just a >
-    )%x', '_filter_xss_split', $string);
+    )%x', 'Drupal\_filter_xss_split', $string);
 }
 
 /**
@@ -1561,7 +1563,7 @@ function _filter_xss_attributes($attr) {
  *   (deprecated) Whether to decode entities in the $string. Set to FALSE if the
  *   $string is in plain text, TRUE otherwise. Defaults to TRUE. This parameter
  *   is deprecated and will be removed in Drupal 8. To process a plain-text URI,
- *   call drupal_strip_dangerous_protocols() or check_url() instead.
+ *   call strip_dangerous_protocols() or check_url() instead.
  *
  * @return
  *   Cleaned up and HTML-escaped version of $string.
@@ -1571,13 +1573,13 @@ function filter_xss_bad_protocol($string, $decode = TRUE) {
   // @todo Remove the $decode parameter in Drupal 8, and always assume an HTML
   //   string that needs decoding.
   if ($decode) {
-    if (!function_exists('decode_entities')) {
-      require_once DRUPAL_ROOT . '/core/includes/unicode.inc';
+    if (!function_exists('Drupal\decode_entities')) {
+      require_once ROOT . '/core/includes/unicode.inc';
     }
 
     $string = decode_entities($string);
   }
-  return check_plain(drupal_strip_dangerous_protocols($string));
+  return check_plain(strip_dangerous_protocols($string));
 }
 
 /**
@@ -1652,7 +1654,7 @@ function format_xml_elements($array) {
       if ($value['key']) {
         $output .= ' <' . $value['key'];
         if (isset($value['attributes']) && is_array($value['attributes'])) {
-          $output .= drupal_attributes($value['attributes']);
+          $output .= attributes($value['attributes']);
         }
 
         if (isset($value['value']) && $value['value'] != '') {
@@ -1722,7 +1724,7 @@ function format_plural($count, $singular, $plural, array $args = array(), array
   }
 
   // Get the plural index through the gettext formula.
-  $index = (function_exists('locale_get_plural')) ? locale_get_plural($count, isset($options['langcode']) ? $options['langcode'] : NULL) : -1;
+  $index = (function_exists('Drupal\locale_get_plural')) ? locale_get_plural($count, isset($options['langcode']) ? $options['langcode'] : NULL) : -1;
   // Backwards compatibility.
   if ($index < 0) {
     return t($plural, $args, $options);
@@ -1756,7 +1758,7 @@ function parse_size($size) {
   $size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size.
   if ($unit) {
     // Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by.
-    return round($size * pow(DRUPAL_KILOBYTE, stripos('bkmgtpezy', $unit[0])));
+    return round($size * pow(KILOBYTE, stripos('bkmgtpezy', $unit[0])));
   }
   else {
     return round($size);
@@ -1776,11 +1778,11 @@ function parse_size($size) {
  *   A translated string representation of the size.
  */
 function format_size($size, $langcode = NULL) {
-  if ($size < DRUPAL_KILOBYTE) {
+  if ($size < KILOBYTE) {
     return format_plural($size, '1 byte', '@count bytes', array(), array('langcode' => $langcode));
   }
   else {
-    $size = $size / DRUPAL_KILOBYTE; // Convert bytes to kilobytes.
+    $size = $size / KILOBYTE; // Convert bytes to kilobytes.
     $units = array(
       t('@size KB', array(), array('langcode' => $langcode)),
       t('@size MB', array(), array('langcode' => $langcode)),
@@ -1792,8 +1794,8 @@ function format_size($size, $langcode = NULL) {
       t('@size YB', array(), array('langcode' => $langcode)),
     );
     foreach ($units as $unit) {
-      if (round($size, 2) >= DRUPAL_KILOBYTE) {
-        $size = $size / DRUPAL_KILOBYTE;
+      if (round($size, 2) >= KILOBYTE) {
+        $size = $size / KILOBYTE;
       }
       else {
         break;
@@ -1873,11 +1875,11 @@ function format_interval($timestamp, $granularity = 2, $langcode = NULL) {
  */
 function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
   // Use the advanced drupal_static() pattern, since this is called very often.
-  static $drupal_static_fast;
-  if (!isset($drupal_static_fast)) {
-    $drupal_static_fast['timezones'] = &drupal_static(__FUNCTION__);
+  static $static_fast;
+  if (!isset($static_fast)) {
+    $static_fast['timezones'] = &drupal_static(__FUNCTION__);
   }
-  $timezones = &$drupal_static_fast['timezones'];
+  $timezones = &$static_fast['timezones'];
 
   if (!isset($timezone)) {
     $timezone = date_default_timezone_get();
@@ -1939,7 +1941,7 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
   _format_date_callback(NULL, $langcode);
 
   // Translate the marked sequences.
-  return preg_replace_callback('/\xEF([AaeDlMTF]?)(.*?)\xFF/', '_format_date_callback', $format);
+  return preg_replace_callback('/\xEF([AaeDlMTF]?)(.*?)\xFF/', 'Drupal\_format_date_callback', $format);
 }
 
 /**
@@ -2074,19 +2076,19 @@ function url($path = NULL, array $options = array()) {
 
   if (!isset($options['external'])) {
     // Return an external link if $path contains an allowed absolute URL. Only
-    // call the slow drupal_strip_dangerous_protocols() if $path contains a ':'
+    // call the slow strip_dangerous_protocols() if $path contains a ':'
     // before any / ? or #. Note: we could use url_is_external($path) here, but
     // that would require another function call, and performance inside url() is
     // critical.
     $colonpos = strpos($path, ':');
-    $options['external'] = ($colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && drupal_strip_dangerous_protocols($path) == $path);
+    $options['external'] = ($colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && strip_dangerous_protocols($path) == $path);
   }
 
   // Preserve the original path before altering or aliasing.
   $original_path = $path;
 
   // Allow other modules to alter the outbound URL and options.
-  drupal_alter('url_outbound', $path, $options, $original_path);
+  alter('url_outbound', $path, $options, $original_path);
 
   if (isset($options['fragment']) && $options['fragment'] !== '') {
     $options['fragment'] = '#' . $options['fragment'];
@@ -2142,7 +2144,7 @@ function url($path = NULL, array $options = array()) {
   }
   elseif (!empty($path) && !$options['alias']) {
     $langcode = isset($options['language']) && isset($options['language']->langcode) ? $options['language']->langcode : '';
-    $alias = drupal_get_path_alias($original_path, $langcode);
+    $alias = get_path_alias($original_path, $langcode);
     if ($alias != $original_path) {
       $path = $alias;
     }
@@ -2153,7 +2155,7 @@ function url($path = NULL, array $options = array()) {
 
   // With Clean URLs.
   if (!empty($GLOBALS['conf']['clean_url'])) {
-    $path = drupal_encode_path($prefix . $path);
+    $path = encode_path($prefix . $path);
     if ($options['query']) {
       return $base . $path . '?' . drupal_http_build_query($options['query']) . $options['fragment'];
     }
@@ -2194,10 +2196,10 @@ function url($path = NULL, array $options = array()) {
  */
 function url_is_external($path) {
   $colonpos = strpos($path, ':');
-  // Avoid calling drupal_strip_dangerous_protocols() if there is any
+  // Avoid calling strip_dangerous_protocols() if there is any
   // slash (/), hash (#) or question_mark (?) before the colon (:)
   // occurrence - if any - as this would clearly mean it is not a URL.
-  return $colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && drupal_strip_dangerous_protocols($path) == $path;
+  return $colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && strip_dangerous_protocols($path) == $path;
 }
 
 /**
@@ -2210,9 +2212,9 @@ function url_is_external($path) {
  *   A ; separated string ready for insertion in a HTTP header. No escaping is
  *   performed for HTML entities, so this string is not safe to be printed.
  *
- * @see drupal_add_http_header()
+ * @see add_http_header()
  */
-function drupal_http_header_attributes(array $attributes = array()) {
+function http_header_attributes(array $attributes = array()) {
   foreach ($attributes as $attribute => &$data) {
     if (is_array($data)) {
       $data = implode(' ', $data);
@@ -2234,20 +2236,20 @@ function drupal_http_header_attributes(array $attributes = array()) {
  * attribute names, it is strongly recommended to allow only white-listed names,
  * since certain attributes carry security risks and can be abused.
  *
- * Examples of security aspects when using drupal_attributes:
+ * Examples of security aspects when using attributes:
  * @code
  *   // By running the value in the following statement through check_plain,
  *   // the malicious script is neutralized.
- *   drupal_attributes(array('title' => t('<script>steal_cookie();</script>')));
+ *   attributes(array('title' => t('<script>steal_cookie();</script>')));
  *
- *   // The statement below demonstrates dangerous use of drupal_attributes, and
+ *   // The statement below demonstrates dangerous use of attributes, and
  *   // will return an onmouseout attribute with JavaScript code that, when used
  *   // as attribute in a tag, will cause users to be redirected to another site.
  *   //
  *   // In this case, the 'onmouseout' attribute should not be whitelisted --
  *   // you don't want users to have the ability to add this attribute or others
  *   // that take JavaScript commands.
- *   drupal_attributes(array('onmouseout' => 'window.location="http://malicious.com/";')));
+ *   attributes(array('onmouseout' => 'window.location="http://malicious.com/";')));
  * @endcode
  *
  * @param $attributes
@@ -2258,7 +2260,7 @@ function drupal_http_header_attributes(array $attributes = array()) {
  *
  * @ingroup sanitization
  */
-function drupal_attributes(array $attributes = array()) {
+function attributes(array $attributes = array()) {
   foreach ($attributes as $attribute => &$data) {
     $data = implode(' ', (array) $data);
     $data = $attribute . '="' . check_plain($data) . '"';
@@ -2287,7 +2289,7 @@ function drupal_attributes(array $attributes = array()) {
  *   - 'attributes': An associative array of HTML attributes to apply to the
  *     anchor tag. If element 'class' is included, it must be an array; 'title'
  *     must be a string; other elements are more flexible, as they just need
- *     to work in a call to drupal_attributes($options['attributes']).
+ *     to work in a call to attributes($options['attributes']).
  *   - 'html' (default FALSE): Whether $text is HTML or just plain-text. For
  *     example, to make an image tag into a link, this must be set to TRUE, or
  *     you will see the escaped HTML image tag. $text is not sanitized if
@@ -2313,7 +2315,7 @@ function l($text, $path, array $options = array()) {
   );
 
   // Append active class.
-  if (($path == $_GET['q'] || ($path == '<front>' && drupal_is_front_page())) &&
+  if (($path == $_GET['q'] || ($path == '<front>' && is_front_page())) &&
       (empty($options['language']) || $options['language']->langcode == $language_url->langcode)) {
     $options['attributes']['class'][] = 'active';
   }
@@ -2331,11 +2333,11 @@ function l($text, $path, array $options = array()) {
   // benchmarks indicate that invoking theme() can slow down the l() function
   // by 20% or more, and that some of the link-heavy Drupal pages spend more
   // than 10% of the total page request time in the l() function.
-  if (!isset($use_theme) && function_exists('theme')) {
+  if (!isset($use_theme) && function_exists('Drupal\theme')) {
     // Allow edge cases to prevent theme initialization and force inline link
     // rendering.
     if (variable_get('theme_link', TRUE)) {
-      drupal_theme_initialize();
+      theme_initialize();
       $registry = theme_get_registry(FALSE);
       // We don't want to duplicate functionality that's in theme(), so any
       // hint of a module or theme doing anything at all special with the 'link'
@@ -2355,15 +2357,15 @@ function l($text, $path, array $options = array()) {
   }
   // The result of url() is a plain-text URL. Because we are using it here
   // in an HTML argument context, we need to encode it properly.
-  return '<a href="' . check_plain(url($path, $options)) . '"' . drupal_attributes($options['attributes']) . '>' . ($options['html'] ? $text : check_plain($text)) . '</a>';
+  return '<a href="' . check_plain(url($path, $options)) . '"' . attributes($options['attributes']) . '>' . ($options['html'] ? $text : check_plain($text)) . '</a>';
 }
 
 /**
  * Delivers a page callback result to the browser in the appropriate format.
  *
  * This function is most commonly called by menu_execute_active_handler(), but
- * can also be called by error conditions such as drupal_not_found(),
- * drupal_access_denied(), and drupal_site_offline().
+ * can also be called by error conditions such as not_found(),
+ * access_denied(), and site_offline().
  *
  * When a user requests a page, index.php calls menu_execute_active_handler(),
  * which calls the 'page callback' function registered in hook_menu(). The page
@@ -2381,7 +2383,7 @@ function l($text, $path, array $options = array()) {
  * this function is to determine the most appropriate 'delivery callback'
  * function to route the content to. The delivery callback function then
  * sends the content to the browser in the needed format. The default delivery
- * callback is drupal_deliver_html_page(), which delivers the content as an HTML
+ * callback is deliver_html_page(), which delivers the content as an HTML
  * page, complete with blocks in addition to the content. This default can be
  * overridden on a per menu router item basis by setting 'delivery callback' in
  * hook_menu() or hook_menu_alter(), and can also be overridden on a per request
@@ -2404,7 +2406,7 @@ function l($text, $path, array $options = array()) {
  * purposes), but it has security implications. Do not call this function
  * directly unless you understand the security implications, and be careful in
  * writing delivery callbacks, so that they do not violate security. See
- * drupal_deliver_html_page() for an example of a delivery callback that
+ * deliver_html_page() for an example of a delivery callback that
  * respects security.
  *
  * @param $page_callback_result
@@ -2424,16 +2426,17 @@ function l($text, $path, array $options = array()) {
  * @see hook_menu_alter()
  * @see hook_page_delivery_callback_alter()
  */
-function drupal_deliver_page($page_callback_result, $default_delivery_callback = NULL) {
+function deliver_page($page_callback_result, $default_delivery_callback = NULL) {
   if (!isset($default_delivery_callback) && ($router_item = menu_get_item())) {
     $default_delivery_callback = $router_item['delivery_callback'];
   }
-  $delivery_callback = !empty($default_delivery_callback) ? $default_delivery_callback : 'drupal_deliver_html_page';
+  $delivery_callback = !empty($default_delivery_callback) ? $default_delivery_callback : 'deliver_html_page';
   // Give modules a chance to alter the delivery callback used, based on
   // request-time context (e.g., HTTP request headers).
-  drupal_alter('page_delivery_callback', $delivery_callback);
-  if (function_exists($delivery_callback)) {
-    $delivery_callback($page_callback_result);
+  alter('page_delivery_callback', $delivery_callback);
+  $function  = 'Drupal\\' . $delivery_callback;
+  if (function_exists($function)) {
+    $function($page_callback_result);
   }
   else {
     // If a delivery callback is specified, but doesn't exist as a function,
@@ -2453,20 +2456,20 @@ function drupal_deliver_page($page_callback_result, $default_delivery_callback =
  *   - A string of HTML content.
  *   - A renderable array of content.
  *
- * @see drupal_deliver_page()
+ * @see deliver_page()
  */
-function drupal_deliver_html_page($page_callback_result) {
+function deliver_html_page($page_callback_result) {
   // Emit the correct charset HTTP header, but not if the page callback
   // result is NULL, since that likely indicates that it printed something
   // in which case, no further headers may be sent, and not if code running
   // for this page request has already set the content type header.
-  if (isset($page_callback_result) && is_null(drupal_get_http_header('Content-Type'))) {
-    drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
+  if (isset($page_callback_result) && is_null(get_http_header('Content-Type'))) {
+    add_http_header('Content-Type', 'text/html; charset=utf-8');
   }
 
   // Send appropriate HTTP-Header for browsers and search engines.
   global $language;
-  drupal_add_http_header('Content-Language', $language->langcode);
+  add_http_header('Content-Language', $language->langcode);
 
   // Menu status constants are integers; page content is a string or array.
   if (is_int($page_callback_result)) {
@@ -2474,19 +2477,19 @@ function drupal_deliver_html_page($page_callback_result) {
     switch ($page_callback_result) {
       case MENU_NOT_FOUND:
         // Print a 404 page.
-        drupal_add_http_header('Status', '404 Not Found');
+        add_http_header('Status', '404 Not Found');
 
         watchdog('page not found', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
 
         // Check for and return a fast 404 page if configured.
-        drupal_fast_404();
+        fast_404();
 
         // Keep old path for reference, and to allow forms to redirect to it.
         if (!isset($_GET['destination'])) {
           $_GET['destination'] = $_GET['q'];
         }
 
-        $path = drupal_get_normal_path(variable_get('site_404', ''));
+        $path = get_normal_path(variable_get('site_404', ''));
         if ($path && $path != $_GET['q']) {
           // Custom 404 handler. Set the active item in case there are tabs to
           // display, or other dependencies on the path.
@@ -2496,18 +2499,18 @@ function drupal_deliver_html_page($page_callback_result) {
 
         if (empty($return) || $return == MENU_NOT_FOUND || $return == MENU_ACCESS_DENIED) {
           // Standard 404 handler.
-          drupal_set_title(t('Page not found'));
+          set_title(t('Page not found'));
           $return = t('The requested page "@path" could not be found.', array('@path' => request_uri()));
         }
 
-        drupal_set_page_content($return);
+        set_page_content($return);
         $page = element_info('page');
-        print drupal_render_page($page);
+        print render_page($page);
         break;
 
       case MENU_ACCESS_DENIED:
         // Print a 403 page.
-        drupal_add_http_header('Status', '403 Forbidden');
+        add_http_header('Status', '403 Forbidden');
         watchdog('access denied', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
 
         // Keep old path for reference, and to allow forms to redirect to it.
@@ -2515,7 +2518,7 @@ function drupal_deliver_html_page($page_callback_result) {
           $_GET['destination'] = $_GET['q'];
         }
 
-        $path = drupal_get_normal_path(variable_get('site_403', ''));
+        $path = get_normal_path(variable_get('site_403', ''));
         if ($path && $path != $_GET['q']) {
           // Custom 403 handler. Set the active item in case there are tabs to
           // display or other dependencies on the path.
@@ -2525,18 +2528,18 @@ function drupal_deliver_html_page($page_callback_result) {
 
         if (empty($return) || $return == MENU_NOT_FOUND || $return == MENU_ACCESS_DENIED) {
           // Standard 403 handler.
-          drupal_set_title(t('Access denied'));
+          set_title(t('Access denied'));
           $return = t('You are not authorized to access this page.');
         }
 
-        print drupal_render_page($return);
+        print render_page($return);
         break;
 
       case MENU_SITE_OFFLINE:
         // Print a 503 page.
-        drupal_maintenance_theme();
-        drupal_add_http_header('Status', '503 Service unavailable');
-        drupal_set_title(t('Site under maintenance'));
+        maintenance_theme();
+        add_http_header('Status', '503 Service unavailable');
+        set_title(t('Site under maintenance'));
         print theme('maintenance_page', array('content' => filter_xss_admin(variable_get('maintenance_mode_message',
           t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))))));
         break;
@@ -2545,11 +2548,11 @@ function drupal_deliver_html_page($page_callback_result) {
   elseif (isset($page_callback_result)) {
     // Print anything besides a menu constant, assuming it's not NULL or
     // undefined.
-    print drupal_render_page($page_callback_result);
+    print render_page($page_callback_result);
   }
 
   // Perform end-of-request tasks.
-  drupal_page_footer();
+  page_footer();
 }
 
 /**
@@ -2558,23 +2561,23 @@ function drupal_deliver_html_page($page_callback_result) {
  * This function sets the page cache if appropriate, and allows modules to
  * react to the closing of the page by calling hook_exit().
  */
-function drupal_page_footer() {
+function page_footer() {
   global $user;
 
   module_invoke_all('exit');
 
   // Commit the user session, if needed.
-  drupal_session_commit();
+  session_commit();
 
-  if (variable_get('cache', 0) && ($cache = drupal_page_set_cache())) {
-    drupal_serve_page_from_cache($cache);
+  if (variable_get('cache', 0) && ($cache = page_set_cache())) {
+    serve_page_from_cache($cache);
   }
   else {
     ob_flush();
   }
 
   _registry_check_code(REGISTRY_WRITE_LOOKUP_CACHE);
-  drupal_cache_system_paths();
+  cache_system_paths();
   module_implements_write_cache();
   system_run_automated_cron();
 }
@@ -2582,21 +2585,21 @@ function drupal_page_footer() {
 /**
  * Performs end-of-request tasks.
  *
- * In some cases page requests need to end without calling drupal_page_footer().
+ * In some cases page requests need to end without calling page_footer().
  * In these cases, call drupal_exit() instead. There should rarely be a reason
  * to call exit instead of drupal_exit();
  *
  * @param $destination
- *   If this function is called from drupal_goto(), then this argument
+ *   If this function is called from redirect(), then this argument
  *   will be a fully-qualified URL that is the destination of the redirect.
  *   This should be passed along to hook_exit() implementations.
  */
 function drupal_exit($destination = NULL) {
-  if (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL) {
+  if (get_bootstrap_phase() == BOOTSTRAP_FULL) {
     if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') {
       module_invoke_all('exit', $destination);
     }
-    drupal_session_commit();
+    session_commit();
   }
   exit;
 }
@@ -2618,7 +2621,7 @@ function drupal_exit($destination = NULL) {
  * @return
  *   An associative array.
  */
-function drupal_map_assoc($array, $function = NULL) {
+function map_assoc($array, $function = NULL) {
   // array_combine() fails with empty arrays:
   // http://bugs.php.net/bug.php?id=34857.
   $array = !empty($array) ? array_combine($array, $array) : array();
@@ -2673,8 +2676,8 @@ function drupal_set_time_limit($time_limit) {
  * @return
  *   The path to the requested item.
  */
-function drupal_get_path($type, $name) {
-  return dirname(drupal_get_filename($type, $name));
+function get_path($type, $name) {
+  return dirname(get_filename($type, $name));
 }
 
 /**
@@ -2704,7 +2707,7 @@ function base_path() {
  * @param $header
  *   Optional flag to determine if a HTTP 'Link:' header should be sent.
  */
-function drupal_add_html_head_link($attributes, $header = FALSE) {
+function add_html_head_link($attributes, $header = FALSE) {
   $element = array(
     '#tag' => 'link',
     '#attributes' => $attributes,
@@ -2715,16 +2718,16 @@ function drupal_add_html_head_link($attributes, $header = FALSE) {
     // Also add a HTTP header "Link:".
     $href = '<' . check_plain($attributes['href']) . '>;';
     unset($attributes['href']);
-    $element['#attached']['drupal_add_http_header'][] = array('Link',  $href . drupal_http_header_attributes($attributes), TRUE);
+    $element['#attached']['add_http_header'][] = array('Link',  $href . http_header_attributes($attributes), TRUE);
   }
 
-  drupal_add_html_head($element, 'drupal_add_html_head_link:' . $attributes['rel'] . ':' . $href);
+  add_html_head($element, 'add_html_head_link:' . $attributes['rel'] . ':' . $href);
 }
 
 /**
  * Adds a cascading stylesheet to the stylesheet queue.
  *
- * Calling drupal_static_reset('drupal_add_css') will clear all cascading
+ * Calling drupal_static_reset('add_css') will clear all cascading
  * stylesheets added so far.
  *
  * If CSS aggregation/compression is enabled, all cascading style sheets added
@@ -2743,7 +2746,7 @@ function drupal_add_html_head_link($attributes, $header = FALSE) {
  * all typical visitors and most pages of a site. It is critical that all
  * preprocessed files are added unconditionally on every page, even if the
  * files do not happen to be needed on a page. This is normally done by calling
- * drupal_add_css() in a hook_init() implementation.
+ * add_css() in a hook_init() implementation.
  *
  * Non-preprocessed files should only be added to the page when they are
  * actually needed.
@@ -2758,7 +2761,7 @@ function drupal_add_html_head_link($attributes, $header = FALSE) {
  *     example, system-menus.css rather than simply menus.css. Themes can
  *     override module-supplied CSS files based on their filenames, and this
  *     prefixing helps prevent confusing name collisions for theme developers.
- *     See drupal_get_css() where the overrides are performed. Also, if the
+ *     See get_css() where the overrides are performed. Also, if the
  *     direction of the current language is right-to-left (Hebrew, Arabic,
  *     etc.), the function will also look for an RTL CSS file and append it to
  *     the list. The name of this file should have an '-rtl.css' suffix. For
@@ -2821,23 +2824,23 @@ function drupal_add_html_head_link($attributes, $header = FALSE) {
  *     - Then by the 'every_page' flag, with TRUE coming before FALSE.
  *     - Then by weight.
  *     - Then by the order in which the CSS was added. For example, all else
- *       being the same, a stylesheet added by a call to drupal_add_css() that
+ *       being the same, a stylesheet added by a call to add_css() that
  *       happened later in the page request gets added to the page after one for
- *       which drupal_add_css() happened earlier in the page request.
+ *       which add_css() happened earlier in the page request.
  *   - 'media': The media type for the stylesheet, e.g., all, print, screen.
  *     Defaults to 'all'.
  *   - 'preprocess': If TRUE and CSS aggregation/compression is enabled, the
  *     styles will be aggregated and compressed. Defaults to TRUE.
  *   - 'browsers': An array containing information specifying which browsers
- *     should load the CSS item. See drupal_pre_render_conditional_comments()
+ *     should load the CSS item. See pre_render_conditional_comments()
  *     for details.
  *
  * @return
  *   An array of queued cascading stylesheets.
  *
- * @see drupal_get_css()
+ * @see get_css()
  */
-function drupal_add_css($data = NULL, $options = NULL) {
+function add_css($data = NULL, $options = NULL) {
   $css = &drupal_static(__FUNCTION__, array());
 
   // Construct the options, taking the defaults into consideration.
@@ -2913,34 +2916,34 @@ function drupal_add_css($data = NULL, $options = NULL) {
  *   (optional) An array of CSS files. If no array is provided, the default
  *   stylesheets array is used instead.
  * @param $skip_alter
- *   (optional) If set to TRUE, this function skips calling drupal_alter() on
+ *   (optional) If set to TRUE, this function skips calling alter() on
  *   $css, useful when the calling function passes a $css array that has already
  *   been altered.
  *
  * @return
  *   A string of XHTML CSS tags.
  *
- * @see drupal_add_css()
+ * @see add_css()
  */
-function drupal_get_css($css = NULL, $skip_alter = FALSE) {
+function get_css($css = NULL, $skip_alter = FALSE) {
   if (!isset($css)) {
-    $css = drupal_add_css();
+    $css = add_css();
   }
 
   // Allow modules and themes to alter the CSS items.
   if (!$skip_alter) {
-    drupal_alter('css', $css);
+    alter('css', $css);
   }
 
   // Sort CSS items, so that they appear in the correct order.
-  uasort($css, 'drupal_sort_css_js');
+  uasort($css, 'Drupal\sort_css_js');
 
   // Remove the overridden CSS files. Later CSS files override former ones.
   $previous_item = array();
   foreach ($css as $key => $item) {
     if ($item['type'] == 'file') {
       // If defined, force a unique basename for this file.
-      $basename = isset($item['basename']) ? $item['basename'] : drupal_basename($item['data']);
+      $basename = isset($item['basename']) ? $item['basename'] : basename($item['data']);
       if (isset($previous_item[$basename])) {
         // Remove the previous item that shared the same base name.
         unset($css[$previous_item[$basename]]);
@@ -2972,8 +2975,8 @@ function drupal_get_css($css = NULL, $skip_alter = FALSE) {
  * Sorts CSS and JavaScript resources.
  *
  * Callback for uasort() within:
- * - drupal_get_css()
- * - drupal_get_js()
+ * - get_css()
+ * - get_js()
  *
  * This sort order helps optimize front-end performance while providing modules
  * and themes with the necessary control for ordering the CSS and JavaScript
@@ -2981,14 +2984,14 @@ function drupal_get_css($css = NULL, $skip_alter = FALSE) {
  *
  * @param $a
  *   First item for comparison. The compared items should be associative arrays
- *   of member items from drupal_add_css() or drupal_add_js().
+ *   of member items from add_css() or add_js().
  * @param $b
  *   Second item for comparison.
  *
- * @see drupal_add_css()
- * @see drupal_add_js()
+ * @see add_css()
+ * @see add_js()
  */
-function drupal_sort_css_js($a, $b) {
+function sort_css_js($a, $b) {
   // First order by group, so that, for example, all items in the CSS_SYSTEM
   // group appear before items in the CSS_DEFAULT group, which appear before
   // all items in the CSS_THEME group. Modules may create additional groups by
@@ -3043,8 +3046,8 @@ function drupal_sort_css_js($a, $b) {
  * between.
  *
  * @param $css
- *   An array of CSS items, as returned by drupal_add_css(), but after
- *   alteration performed by drupal_get_css().
+ *   An array of CSS items, as returned by add_css(), but after
+ *   alteration performed by get_css().
  *
  * @return
  *   An array of CSS groups. Each group contains the same keys (e.g., 'media',
@@ -3052,10 +3055,10 @@ function drupal_sort_css_js($a, $b) {
  *   each key applying to the group as a whole. Each group also contains an
  *   'items' key, which is the subset of items from $css that are in the group.
  *
- * @see drupal_pre_render_styles()
+ * @see pre_render_styles()
  * @see system_element_info()
  */
-function drupal_group_css($css) {
+function group_css($css) {
   $groups = array();
   // If a group can contain multiple items, we track the information that must
   // be the same for each item in the group, so that when we iterate the next
@@ -3087,7 +3090,7 @@ function drupal_group_css($css) {
         // Group file items if their 'preprocess' flag is TRUE.
         // Help ensure maximum reuse of aggregate files by only grouping
         // together items that share the same 'group' value and 'every_page'
-        // flag. See drupal_add_css() for details about that.
+        // flag. See add_css() for details about that.
         $group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['every_page'], $item['media'], $item['browsers']) : FALSE;
         break;
       case 'inline':
@@ -3131,14 +3134,14 @@ function drupal_group_css($css) {
  * content together, regardless of the site-wide aggregation setting.
  *
  * @param $css_groups
- *   An array of CSS groups as returned by drupal_group_css(). This function
+ *   An array of CSS groups as returned by group_css(). This function
  *   modifies the group's 'data' property for each group that is aggregated.
  *
- * @see drupal_group_css()
- * @see drupal_pre_render_styles()
+ * @see group_css()
+ * @see pre_render_styles()
  * @see system_element_info()
  */
-function drupal_aggregate_css(&$css_groups) {
+function aggregate_css(&$css_groups) {
   $preprocess_css = (variable_get('preprocess_css', FALSE) && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update'));
 
   // For each group that needs aggregation, aggregate its items.
@@ -3148,14 +3151,14 @@ function drupal_aggregate_css(&$css_groups) {
       // the group's data property to the file path of the aggregate file.
       case 'file':
         if ($group['preprocess'] && $preprocess_css) {
-          $css_groups[$key]['data'] = drupal_build_css_cache($group['items']);
+          $css_groups[$key]['data'] = build_css_cache($group['items']);
         }
         break;
       // Aggregate all inline CSS content into the group's data property.
       case 'inline':
         $css_groups[$key]['data'] = '';
         foreach ($group['items'] as $item) {
-          $css_groups[$key]['data'] .= drupal_load_stylesheet_content($item['data'], $item['preprocess']);
+          $css_groups[$key]['data'] .= load_stylesheet_content($item['data'], $item['preprocess']);
         }
         break;
     }
@@ -3210,8 +3213,8 @@ function drupal_aggregate_css(&$css_groups) {
  *
  * @param $element
  *   A render array containing:
- *   - '#items': The CSS items as returned by drupal_add_css() and altered by
- *     drupal_get_css().
+ *   - '#items': The CSS items as returned by add_css() and altered by
+ *     get_css().
  *   - '#group_callback': A function to call to group #items to enable the use
  *     of fewer tags by aggregating files and/or using multiple @import
  *     statements within a single tag.
@@ -3221,15 +3224,17 @@ function drupal_aggregate_css(&$css_groups) {
  * @return
  *   A render array that will render to a string of XHTML CSS tags.
  *
- * @see drupal_get_css()
+ * @see get_css()
  */
-function drupal_pre_render_styles($elements) {
+function pre_render_styles($elements) {
   // Group and aggregate the items.
   if (isset($elements['#group_callback'])) {
-    $elements['#groups'] = $elements['#group_callback']($elements['#items']);
+    $function = 'Drupal\\' . $elements['#group_callback'];
+    $elements['#groups'] = $function($elements['#items']);
   }
   if (isset($elements['#aggregate_callback'])) {
-    $elements['#aggregate_callback']($elements['#groups']);
+    $function = 'Drupal\\' . $elements['#aggregate_callback'];
+    $function($elements['#groups']);
   }
 
   // A dummy query-string is added to filenames, to gain control over
@@ -3294,7 +3299,7 @@ function drupal_pre_render_styles($elements) {
             // On a server under heavy enough load that file_exists() calls need
             // to be minimized, CSS aggregation should be enabled, in which case
             // this code is not run. When aggregation is enabled,
-            // drupal_load_stylesheet() checks file_exists(), but only when
+            // load_stylesheet() checks file_exists(), but only when
             // building the aggregate file, which is then reused for many page
             // requests.
             if (file_exists($item['data'])) {
@@ -3397,7 +3402,7 @@ function drupal_pre_render_styles($elements) {
  * variable is emptied to force a rebuild of the cache. Second, the cache file
  * is generated if it is missing on disk. Old cache files are not deleted
  * immediately when the lookup variable is emptied, but are deleted after a set
- * period by drupal_delete_file_if_stale(). This ensures that files referenced
+ * period by delete_file_if_stale(). This ensures that files referenced
  * by a cached page will still be available.
  *
  * @param $css
@@ -3406,7 +3411,7 @@ function drupal_pre_render_styles($elements) {
  * @return
  *   The URI of the CSS cache file, or FALSE if the file could not be saved.
  */
-function drupal_build_css_cache($css) {
+function build_css_cache($css) {
   $data = '';
   $uri = '';
   $map = variable_get('drupal_css_cache_files', array());
@@ -3420,7 +3425,7 @@ function drupal_build_css_cache($css) {
     foreach ($css as $stylesheet) {
       // Only 'file' stylesheets can be aggregated.
       if ($stylesheet['type'] == 'file') {
-        $contents = drupal_load_stylesheet($stylesheet['data'], TRUE);
+        $contents = load_stylesheet($stylesheet['data'], TRUE);
 
         // Build the base URL of this CSS file: start with the full URL.
         $css_base_url = file_create_url($stylesheet['data']);
@@ -3432,9 +3437,9 @@ function drupal_build_css_cache($css) {
           $css_base_url = substr($css_base_url, strlen($GLOBALS['base_root']));
         }
 
-        _drupal_build_css_path(NULL, $css_base_url . '/');
+        _build_css_path(NULL, $css_base_url . '/');
         // Anchor all paths in the CSS with its base URL, ignoring external and absolute paths.
-        $data .= preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', '_drupal_build_css_path', $contents);
+        $data .= preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', 'Drupal\_build_css_path', $contents);
       }
     }
 
@@ -3447,7 +3452,7 @@ function drupal_build_css_cache($css) {
 
     // Prefix filename to prevent blocking by firewalls which reject files
     // starting with "ad*".
-    $filename = 'css_' . drupal_hash_base64($data) . '.css';
+    $filename = 'css_' . hash_base64($data) . '.css';
     // Create the css/ within the files folder.
     $csspath = 'public://css';
     $uri = $csspath . '/' . $filename;
@@ -3473,9 +3478,9 @@ function drupal_build_css_cache($css) {
 }
 
 /**
- * Prefixes all paths within a CSS file for drupal_build_css_cache().
+ * Prefixes all paths within a CSS file for build_css_cache().
  */
-function _drupal_build_css_path($matches, $base = NULL) {
+function _build_css_path($matches, $base = NULL) {
   $_base = &drupal_static(__FUNCTION__);
   // Store base path for preg_replace_callback.
   if (isset($base)) {
@@ -3513,7 +3518,7 @@ function _drupal_build_css_path($matches, $base = NULL) {
  * @return
  *   Contents of the stylesheet, including any resolved @import commands.
  */
-function drupal_load_stylesheet($file, $optimize = NULL, $reset_basepath = TRUE) {
+function load_stylesheet($file, $optimize = NULL, $reset_basepath = TRUE) {
   // These statics are not cache variables, so we don't use drupal_static().
   static $_optimize, $basepath;
   if ($reset_basepath) {
@@ -3537,7 +3542,7 @@ function drupal_load_stylesheet($file, $optimize = NULL, $reset_basepath = TRUE)
   // but are merely there to disable certain module CSS files.
   if ($contents = @file_get_contents($file)) {
     // Return the processed stylesheet.
-    return drupal_load_stylesheet_content($contents, $_optimize);
+    return load_stylesheet_content($contents, $_optimize);
   }
 
   return '';
@@ -3555,7 +3560,7 @@ function drupal_load_stylesheet($file, $optimize = NULL, $reset_basepath = TRUE)
  * @return
  *   Contents of the stylesheet including the imported stylesheets.
  */
-function drupal_load_stylesheet_content($contents, $optimize = FALSE) {
+function load_stylesheet_content($contents, $optimize = FALSE) {
   // Remove multiple charset declarations for standards compliance (and fixing Safari problems).
   $contents = preg_replace('/^@charset\s+[\'"](\S*)\b[\'"];/i', '', $contents);
 
@@ -3601,7 +3606,7 @@ function drupal_load_stylesheet_content($contents, $optimize = FALSE) {
 
   // Replaces @import commands with the actual stylesheet content.
   // This happens recursively but omits external files.
-  $contents = preg_replace_callback('/@import\s*(?:url\(\s*)?[\'"]?(?![a-z]+:)([^\'"\()]+)[\'"]?\s*\)?\s*;/', '_drupal_load_stylesheet', $contents);
+  $contents = preg_replace_callback('/@import\s*(?:url\(\s*)?[\'"]?(?![a-z]+:)([^\'"\()]+)[\'"]?\s*\)?\s*;/', 'Drupal\_load_stylesheet', $contents);
   return $contents;
 }
 
@@ -3611,10 +3616,10 @@ function drupal_load_stylesheet_content($contents, $optimize = FALSE) {
  * This function is used for recursive loading of stylesheets and
  * returns the stylesheet content with all url() paths corrected.
  */
-function _drupal_load_stylesheet($matches) {
+function _load_stylesheet($matches) {
   $filename = $matches[1];
   // Load the imported stylesheet and replace @import commands in there as well.
-  $file = drupal_load_stylesheet($filename, NULL, FALSE);
+  $file = load_stylesheet($filename, NULL, FALSE);
 
   // Determine the file's directory.
   $directory = dirname($filename);
@@ -3631,19 +3636,19 @@ function _drupal_load_stylesheet($matches) {
 /**
  * Deletes old cached CSS files.
  */
-function drupal_clear_css_cache() {
+function clear_css_cache() {
   variable_del('drupal_css_cache_files');
-  file_scan_directory('public://css', '/.*/', array('callback' => 'drupal_delete_file_if_stale'));
+  file_scan_directory('public://css', '/.*/', array('callback' => 'delete_file_if_stale'));
 }
 
 /**
  * Deletes files modified more than a set time ago.
  *
  * Callback for file_scan_directory() within:
- * - drupal_clear_css_cache()
- * - drupal_clear_js_cache()
+ * - clear_css_cache()
+ * - clear_js_cache()
  */
-function drupal_delete_file_if_stale($uri) {
+function delete_file_if_stale($uri) {
   // Default stale file threshold is 30 days.
   if (REQUEST_TIME - filemtime($uri) > variable_get('drupal_stale_file_threshold', 2592000)) {
     file_unmanaged_delete($uri);
@@ -3664,7 +3669,7 @@ function drupal_delete_file_if_stale($uri) {
  * @return
  *   The cleaned identifier.
  */
-function drupal_clean_css_identifier($identifier, $filter = array(' ' => '-', '_' => '-', '/' => '-', '[' => '-', ']' => '')) {
+function clean_css_identifier($identifier, $filter = array(' ' => '-', '_' => '-', '/' => '-', '[' => '-', ']' => '')) {
   // By default, we filter using Drupal's coding standards.
   $identifier = strtr($identifier, $filter);
 
@@ -3693,8 +3698,8 @@ function drupal_clean_css_identifier($identifier, $filter = array(' ' => '-', '_
  * @return
  *   The cleaned class name.
  */
-function drupal_html_class($class) {
-  return drupal_clean_css_identifier(drupal_strtolower($class));
+function html_class($class) {
+  return clean_css_identifier(drupal_strtolower($class));
 }
 
 /**
@@ -3724,7 +3729,7 @@ function drupal_html_class($class) {
  * @return
  *   The cleaned ID.
  */
-function drupal_html_id($id) {
+function html_id($id) {
   // If this is an Ajax request, then content returned by this page request will
   // be merged with content already on the base page. The HTML IDs must be
   // unique for the fully merged content. Therefore, initialize $seen_ids to
@@ -3812,8 +3817,8 @@ function drupal_html_id($id) {
  *
  * @see template_preprocess_region()
  */
-function drupal_region_class($region) {
-  return drupal_html_class("region-$region");
+function region_class($region) {
+  return html_class("region-$region");
 }
 
 /**
@@ -3842,17 +3847,17 @@ function drupal_region_class($region) {
  *
  * Examples:
  * @code
- *   drupal_add_js('core/misc/collapse.js');
- *   drupal_add_js('core/misc/collapse.js', 'file');
- *   drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', 'inline');
- *   drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });',
+ *   add_js('core/misc/collapse.js');
+ *   add_js('core/misc/collapse.js', 'file');
+ *   add_js('jQuery(document).ready(function () { alert("Hello!"); });', 'inline');
+ *   add_js('jQuery(document).ready(function () { alert("Hello!"); });',
  *     array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
  *   );
- *   drupal_add_js('http://example.com/example.js', 'external');
- *   drupal_add_js(array('myModule' => array('key' => 'value')), 'setting');
+ *   add_js('http://example.com/example.js', 'external');
+ *   add_js(array('myModule' => array('key' => 'value')), 'setting');
  * @endcode
  *
- * Calling drupal_static_reset('drupal_add_js') will clear all JavaScript added
+ * Calling drupal_static_reset('add_js') will clear all JavaScript added
  * so far.
  *
  * If JavaScript aggregation is enabled, all JavaScript files added with
@@ -3869,7 +3874,7 @@ function drupal_region_class($region) {
  * all typical visitors and most pages of a site. It is critical that all
  * preprocessed files are added unconditionally on every page, even if the
  * files are not needed on a page. This is normally done by calling
- * drupal_add_js() in a hook_init() implementation.
+ * add_js() in a hook_init() implementation.
  *
  * Non-preprocessed files should only be added to the page when they are
  * actually needed.
@@ -3945,9 +3950,9 @@ function drupal_region_class($region) {
  *     - Then by the 'every_page' flag, with TRUE coming before FALSE.
  *     - Then by weight.
  *     - Then by the order in which the JavaScript was added. For example, all
- *       else being the same, JavaScript added by a call to drupal_add_js() that
+ *       else being the same, JavaScript added by a call to add_js() that
  *       happened later in the page request gets added to the page after one for
- *       which drupal_add_js() happened earlier in the page request.
+ *       which add_js() happened earlier in the page request.
  *   - defer: If set to TRUE, the defer attribute is set on the &lt;script&gt;
  *     tag. Defaults to FALSE.
  *   - cache: If set to FALSE, the JavaScript file is loaded anew on every page
@@ -3957,16 +3962,16 @@ function drupal_region_class($region) {
  *     file will be aggregated. Defaults to TRUE.
  *   - browsers: An array containing information specifying which browsers
  *     should load the JavaScript item. See
- *     drupal_pre_render_conditional_comments() for details.
+ *     pre_render_conditional_comments() for details.
  *
  * @return
  *   The current array of JavaScript files, settings, and in-line code,
  *   including Drupal defaults, anything previously added with calls to
- *   drupal_add_js(), and this function call's additions.
+ *   add_js(), and this function call's additions.
  *
- * @see drupal_get_js()
+ * @see get_js()
  */
-function drupal_add_js($data = NULL, $options = NULL) {
+function add_js($data = NULL, $options = NULL) {
   $javascript = &drupal_static(__FUNCTION__, array());
 
   // Construct the options, taking the defaults into consideration.
@@ -3978,13 +3983,13 @@ function drupal_add_js($data = NULL, $options = NULL) {
   else {
     $options = array();
   }
-  $options += drupal_js_defaults($data);
+  $options += js_defaults($data);
 
   // Preprocess can only be set if caching is enabled.
   $options['preprocess'] = $options['cache'] ? $options['preprocess'] : FALSE;
 
   // Tweak the weight so that files of the same weight are included in the
-  // order of the calls to drupal_add_js().
+  // order of the calls to add_js().
   $options['weight'] += count($javascript) / 1000;
 
   if (isset($data)) {
@@ -4022,9 +4027,9 @@ function drupal_add_js($data = NULL, $options = NULL) {
         ),
       );
       // Register all required libraries.
-      drupal_add_library('system', 'jquery', TRUE);
-      drupal_add_library('system', 'jquery.once', TRUE);
-      drupal_add_library('system', 'html5shiv', TRUE);
+      add_library('system', 'jquery', TRUE);
+      add_library('system', 'jquery.once', TRUE);
+      add_library('system', 'html5shiv', TRUE);
     }
 
     switch ($options['type']) {
@@ -4053,10 +4058,10 @@ function drupal_add_js($data = NULL, $options = NULL) {
  * @param $data
  *   (optional) The default data parameter for the JavaScript item array.
  *
- * @see drupal_get_js()
- * @see drupal_add_js()
+ * @see get_js()
+ * @see add_js()
  */
-function drupal_js_defaults($data = NULL) {
+function js_defaults($data = NULL) {
   return array(
     'type' => 'file',
     'group' => JS_DEFAULT,
@@ -4082,10 +4087,10 @@ function drupal_js_defaults($data = NULL) {
  *
  * Note that hook_js_alter(&$javascript) is called during this function call
  * to allow alterations of the JavaScript during its presentation. Calls to
- * drupal_add_js() from hook_js_alter() will not be added to the output
+ * add_js() from hook_js_alter() will not be added to the output
  * presentation. The correct way to add JavaScript during hook_js_alter()
  * is to add another element to the $javascript array, deriving from
- * drupal_js_defaults(). See locale_js_alter() for an example of this.
+ * js_defaults(). See locale_js_alter() for an example of this.
  *
  * @param $scope
  *   (optional) The scope for which the JavaScript rules should be returned.
@@ -4094,20 +4099,20 @@ function drupal_js_defaults($data = NULL) {
  *   (optional) An array with all JavaScript code. Defaults to the default
  *   JavaScript array for the given scope.
  * @param $skip_alter
- *   (optional) If set to TRUE, this function skips calling drupal_alter() on
+ *   (optional) If set to TRUE, this function skips calling alter() on
  *   $javascript, useful when the calling function passes a $javascript array
  *   that has already been altered.
  *
  * @return
  *   All JavaScript code segments and includes for the scope as HTML tags.
  *
- * @see drupal_add_js()
+ * @see add_js()
  * @see locale_js_alter()
- * @see drupal_js_defaults()
+ * @see js_defaults()
  */
-function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALSE) {
+function get_js($scope = 'header', $javascript = NULL, $skip_alter = FALSE) {
   if (!isset($javascript)) {
-    $javascript = drupal_add_js();
+    $javascript = add_js();
   }
   if (empty($javascript)) {
     return '';
@@ -4115,7 +4120,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS
 
   // Allow modules to alter the JavaScript.
   if (!$skip_alter) {
-    drupal_alter('js', $javascript);
+    alter('js', $javascript);
   }
 
   // Filter out elements of the given scope.
@@ -4127,18 +4132,18 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS
   }
 
   // Sort the JavaScript so that it appears in the correct order.
-  uasort($items, 'drupal_sort_css_js');
+  uasort($items, 'Drupal\sort_css_js');
 
   // Provide the page with information about the individual JavaScript files
   // used, information not otherwise available when aggregation is enabled.
   $setting['ajaxPageState']['js'] = array_fill_keys(array_keys($items), 1);
   unset($setting['ajaxPageState']['js']['settings']);
-  drupal_add_js($setting, 'setting');
+  add_js($setting, 'setting');
 
   // If we're outputting the header scope, then this might be the final time
-  // that drupal_get_js() is running, so add the setting to this output as well
-  // as to the drupal_add_js() cache. If $items['settings'] doesn't exist, it's
-  // because drupal_get_js() was intentionally passed a $javascript argument
+  // that get_js() is running, so add the setting to this output as well
+  // as to the add_js() cache. If $items['settings'] doesn't exist, it's
+  // because get_js() was intentionally passed a $javascript argument
   // stripped of settings, potentially in order to override how settings get
   // output, so in this case, do not add the setting to this output.
   if ($scope == 'header' && isset($items['settings'])) {
@@ -4165,8 +4170,8 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS
  *
  * @param $element
  *   A render array containing:
- *   - #items: The JavaScript items as returned by drupal_add_js() and
- *     altered by drupal_get_js().
+ *   - #items: The JavaScript items as returned by add_js() and
+ *     altered by get_js().
  *   - #group_callback: A function to call to group #items. Following
  *     this function, #aggregate_callback is called to aggregate items within
  *     the same group into a single file.
@@ -4176,21 +4181,23 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS
  * @return
  *   A render array that will render to a string of JavaScript tags.
  *
- * @see drupal_get_js()
+ * @see get_js()
  */
-function drupal_pre_render_scripts($elements) {
+function pre_render_scripts($elements) {
   // Group and aggregate the items.
   if (isset($elements['#group_callback'])) {
-    $elements['#groups'] = $elements['#group_callback']($elements['#items']);
+    $function = 'Drupal\\' . $elements['#group_callback'];
+    $elements['#groups'] = $function($elements['#items']);
   }
   if (isset($elements['#aggregate_callback'])) {
-    $elements['#aggregate_callback']($elements['#groups']);
+    $function = 'Drupal\\' . $elements['#aggregate_callback'];
+    $function($elements['#groups']);
   }
 
   // A dummy query-string is added to filenames, to gain control over
   // browser-caching. The string changes on every update or full cache
   // flush, forcing browsers to load a new copy of the files, as the
-  // URL changed. Files that should not be cached (see drupal_add_js())
+  // URL changed. Files that should not be cached (see add_js())
   // get REQUEST_TIME as query-string instead, to enforce reload on every
   // page request.
   $default_query_string = variable_get('css_js_query_string', '0');
@@ -4241,7 +4248,7 @@ function drupal_pre_render_scripts($elements) {
         switch ($item['type']) {
           case 'setting':
             $element['#value_prefix'] = $embed_prefix;
-            $element['#value'] = 'jQuery.extend(Drupal.settings, ' . drupal_json_encode(drupal_array_merge_deep_array($item['data'])) . ");";
+            $element['#value'] = 'jQuery.extend(Drupal.settings, ' . drupal_json_encode(array_merge_deep_array($item['data'])) . ");";
             $element['#value_suffix'] = $embed_suffix;
             break;
 
@@ -4289,8 +4296,8 @@ function drupal_pre_render_scripts($elements) {
  * between.
  *
  * @param $javascript
- *   An array of JavaScript items, as returned by drupal_add_js(), but after
- *   alteration performed by drupal_get_js().
+ *   An array of JavaScript items, as returned by add_js(), but after
+ *   alteration performed by get_js().
  *
  * @return
  *   An array of JavaScript groups. Each group contains the same keys (e.g.,
@@ -4299,9 +4306,9 @@ function drupal_pre_render_scripts($elements) {
  *   contains an 'items' key, which is the subset of items from $javascript that
  *   are in the group.
  *
- * @see drupal_pre_render_scripts()
+ * @see pre_render_scripts()
  */
-function drupal_group_js($javascript) {
+function group_js($javascript) {
   $groups = array();
   // If a group can contain multiple items, we track the information that must
   // be the same for each item in the group, so that when we iterate the next
@@ -4321,7 +4328,7 @@ function drupal_group_js($javascript) {
         // Group file items if their 'preprocess' flag is TRUE.
         // Help ensure maximum reuse of aggregate files by only grouping
         // together items that share the same 'group' value and 'every_page'
-        // flag. See drupal_add_js() for details about that.
+        // flag. See add_js() for details about that.
         $group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['every_page'], $item['browsers']) : FALSE;
         break;
 
@@ -4364,20 +4371,20 @@ function drupal_group_js($javascript) {
  * whitespace, and other unnecessary content.
  *
  * @param $js_groups
- *   An array of JavaScript groups as returned by drupal_group_js(). For each
+ *   An array of JavaScript groups as returned by group_js(). For each
  *   group that is aggregated, this function sets the value of the group's
  *   'data' key to the URI of the aggregate file.
  *
- * @see drupal_group_js()
- * @see drupal_pre_render_scripts()
+ * @see group_js()
+ * @see pre_render_scripts()
  */
-function drupal_aggregate_js(&$js_groups) {
+function aggregate_js(&$js_groups) {
   // Only aggregate when the site is configured to do so, and not during an
   // update.
   if (variable_get('preprocess_js', FALSE) && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update')) {
     foreach ($js_groups as $key => $group) {
       if ($group['type'] == 'file' && $group['preprocess']) {
-        $js_groups[$key]['data'] = drupal_build_js_cache($group['items']);
+        $js_groups[$key]['data'] = build_js_cache($group['items']);
       }
     }
   }
@@ -4392,8 +4399,8 @@ function drupal_aggregate_js(&$js_groups) {
  * are the attached data. For example:
  * @code
  * $build['#attached'] = array(
- *   'js' => array(drupal_get_path('module', 'taxonomy') . '/taxonomy.js'),
- *   'css' => array(drupal_get_path('module', 'taxonomy') . '/taxonomy.css'),
+ *   'js' => array(get_path('module', 'taxonomy') . '/taxonomy.js'),
+ *   'css' => array(get_path('module', 'taxonomy') . '/taxonomy.css'),
  * );
  * @endcode
  *
@@ -4401,7 +4408,7 @@ function drupal_aggregate_js(&$js_groups) {
  * other kind of attached data, the array key must be the full name of the
  * callback function and each value an array of arguments. For example:
  * @code
- * $build['#attached']['drupal_add_http_header'] = array(
+ * $build['#attached']['add_http_header'] = array(
  *   array('Content-Type', 'application/rss+xml; charset=utf-8'),
  * );
  * @endcode
@@ -4434,12 +4441,12 @@ function drupal_aggregate_js(&$js_groups) {
  *   FALSE if there were any missing library dependencies; TRUE if all library
  *   dependencies were met.
  *
- * @see drupal_add_library()
- * @see drupal_add_js()
- * @see drupal_add_css()
+ * @see add_library()
+ * @see add_js()
+ * @see add_css()
  * @see drupal_render()
  */
-function drupal_process_attached($elements, $group = JS_DEFAULT, $dependency_check = FALSE, $every_page = NULL) {
+function process_attached($elements, $group = JS_DEFAULT, $dependency_check = FALSE, $every_page = NULL) {
   // Add defaults to the special attached structures that should be processed differently.
   $elements['#attached'] += array(
     'library' => array(),
@@ -4450,7 +4457,7 @@ function drupal_process_attached($elements, $group = JS_DEFAULT, $dependency_che
   // Add the libraries first.
   $success = TRUE;
   foreach ($elements['#attached']['library'] as $library) {
-    if (drupal_add_library($library[0], $library[1], $every_page) === FALSE) {
+    if (add_library($library[0], $library[1], $every_page) === FALSE) {
       $success = FALSE;
       // Exit if the dependency is missing.
       if ($dependency_check) {
@@ -4461,7 +4468,7 @@ function drupal_process_attached($elements, $group = JS_DEFAULT, $dependency_che
   unset($elements['#attached']['library']);
 
   // Add both the JavaScript and the CSS.
-  // The parameters for drupal_add_js() and drupal_add_css() require special
+  // The parameters for add_js() and add_css() require special
   // handling.
   foreach (array('js', 'css') as $type) {
     foreach ($elements['#attached'][$type] as $data => $options) {
@@ -4485,7 +4492,7 @@ function drupal_process_attached($elements, $group = JS_DEFAULT, $dependency_che
       if (isset($every_page)) {
         $options['every_page'] = $every_page;
       }
-      call_user_func('drupal_add_' . $type, $data, $options);
+      call_user_func('Drupal\add_' . $type, $data, $options);
     }
     unset($elements['#attached'][$type]);
   }
@@ -4495,7 +4502,7 @@ function drupal_process_attached($elements, $group = JS_DEFAULT, $dependency_che
   // special handling.
   foreach ($elements['#attached'] as $callback => $options) {
     foreach ($elements['#attached'][$callback] as $args) {
-      call_user_func_array($callback, $args);
+      call_user_func_array('Drupal\\' . $callback, $args);
     }
   }
 
@@ -4625,7 +4632,7 @@ function drupal_process_attached($elements, $group = JS_DEFAULT, $dependency_che
  *
  * @see form_example_states_form()
  */
-function drupal_process_states(&$elements) {
+function process_states(&$elements) {
   $elements['#attached']['library'][] = array('system', 'drupal.states');
   $elements['#attached']['js'][] = array(
     'type' => 'setting',
@@ -4655,23 +4662,23 @@ function drupal_process_states(&$elements) {
  *   TRUE if the library was successfully added; FALSE if the library or one of
  *   its dependencies could not be added.
  *
- * @see drupal_get_library()
+ * @see get_library()
  * @see hook_library_info()
  * @see hook_library_info_alter()
  */
-function drupal_add_library($module, $name, $every_page = NULL) {
+function add_library($module, $name, $every_page = NULL) {
   $added = &drupal_static(__FUNCTION__, array());
 
   // Only process the library if it exists and it was not added already.
   if (!isset($added[$module][$name])) {
-    if ($library = drupal_get_library($module, $name)) {
+    if ($library = get_library($module, $name)) {
       // Add all components within the library.
       $elements['#attached'] = array(
         'library' => $library['dependencies'],
         'js' => $library['js'],
         'css' => $library['css'],
       );
-      $added[$module][$name] = drupal_process_attached($elements, JS_LIBRARY, TRUE, $every_page);
+      $added[$module][$name] = process_attached($elements, JS_LIBRARY, TRUE, $every_page);
     }
     else {
       // Requested library does not exist.
@@ -4706,14 +4713,14 @@ function drupal_add_library($module, $name, $every_page = NULL) {
  *   or FALSE if it does not exist. If no $name was passed, an associative array
  *   of libraries registered by $module is returned (which may be empty).
  *
- * @see drupal_add_library()
+ * @see add_library()
  * @see hook_library_info()
  * @see hook_library_info_alter()
  *
  * @todo The purpose of drupal_get_*() is completely different to other page
  *   requisite API functions; find and use a different name.
  */
-function drupal_get_library($module, $name = NULL) {
+function get_library($module, $name = NULL) {
   $libraries = &drupal_static(__FUNCTION__, array());
 
   if (!isset($libraries[$module])) {
@@ -4723,7 +4730,7 @@ function drupal_get_library($module, $name = NULL) {
       $module_libraries = array();
     }
     // Allow modules to alter the module's registered libraries.
-    drupal_alter('library_info', $module_libraries, $module);
+    alter('library_info', $module_libraries, $module);
 
     foreach ($module_libraries as $key => $data) {
       if (is_array($data)) {
@@ -4785,9 +4792,9 @@ function drupal_get_library($module, $name = NULL) {
  * - Rows with the 'tabledrag-leaf' class cannot have child rows.
  * - Rows with the 'tabledrag-root' class cannot be nested under a parent row.
  *
- * Calling drupal_add_tabledrag() would then be written as such:
+ * Calling add_tabledrag() would then be written as such:
  * @code
- * drupal_add_tabledrag('my-module-table', 'order', 'sibling', 'my-elements-weight');
+ * add_tabledrag('my-module-table', 'order', 'sibling', 'my-elements-weight');
  * @endcode
  *
  * In a more complex case where there are several groups in one column (such as
@@ -4799,11 +4806,11 @@ function drupal_get_library($module, $name = NULL) {
  *
  * $group is still 'my-element-weight', and the additional $subgroup variable
  * will be passed in as 'my-elements-weight-' . $region. This also means that
- * you'll need to call drupal_add_tabledrag() once for every region added.
+ * you'll need to call add_tabledrag() once for every region added.
  *
  * @code
  * foreach ($regions as $region) {
- *   drupal_add_tabledrag('my-module-table', 'order', 'sibling', 'my-elements-weight', 'my-elements-weight-' . $region);
+ *   add_tabledrag('my-module-table', 'order', 'sibling', 'my-elements-weight', 'my-elements-weight-' . $region);
  * }
  * @endcode
  *
@@ -4816,7 +4823,7 @@ function drupal_get_library($module, $name = NULL) {
  * Note that this function should be called from the theme layer, such as in a
  * .tpl.php file, theme_ function, or in a template_preprocess function, not in
  * a form declaration. Though the same JavaScript could be added to the page
- * using drupal_add_js() directly, this function helps keep template files
+ * using add_js() directly, this function helps keep template files
  * clean and readable. It also prevents tabledrag.js from being added twice
  * accidentally.
  *
@@ -4852,14 +4859,14 @@ function drupal_get_library($module, $name = NULL) {
  * @see block-admin-display-form.tpl.php
  * @see theme_menu_overview_form()
  */
-function drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup = NULL, $source = NULL, $hidden = TRUE, $limit = 0) {
+function add_tabledrag($table_id, $action, $relationship, $group, $subgroup = NULL, $source = NULL, $hidden = TRUE, $limit = 0) {
   $js_added = &drupal_static(__FUNCTION__, FALSE);
   if (!$js_added) {
     // Add the table drag JavaScript to the page before the module JavaScript
     // to ensure that table drag behaviors are registered before any module
     // uses it.
-    drupal_add_library('system', 'jquery.cookie');
-    drupal_add_js('core/misc/tabledrag.js', array('weight' => -1));
+    add_library('system', 'jquery.cookie');
+    add_js('core/misc/tabledrag.js', array('weight' => -1));
     $js_added = TRUE;
   }
 
@@ -4874,7 +4881,7 @@ function drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgro
     'hidden' => $hidden,
     'limit' => $limit,
   );
-  drupal_add_js($settings, 'setting');
+  add_js($settings, 'setting');
 }
 
 /**
@@ -4892,7 +4899,7 @@ function drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgro
  * variable is emptied to force a rebuild of the cache. Second, the cache file
  * is generated if it is missing on disk. Old cache files are not deleted
  * immediately when the lookup variable is emptied, but are deleted after a set
- * period by drupal_delete_file_if_stale(). This ensures that files referenced
+ * period by delete_file_if_stale(). This ensures that files referenced
  * by a cached page will still be available.
  *
  * @param $files
@@ -4901,7 +4908,7 @@ function drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgro
  * @return
  *   The URI of the cache file, or FALSE if the file could not be saved.
  */
-function drupal_build_js_cache($files) {
+function build_js_cache($files) {
   $contents = '';
   $uri = '';
   $map = variable_get('drupal_js_cache_files', array());
@@ -4920,7 +4927,7 @@ function drupal_build_js_cache($files) {
     }
     // Prefix filename to prevent blocking by firewalls which reject files
     // starting with "ad*".
-    $filename = 'js_' . drupal_hash_base64($contents) . '.js';
+    $filename = 'js_' . hash_base64($contents) . '.js';
     // Create the js/ within the files folder.
     $jspath = 'public://js';
     $uri = $jspath . '/' . $filename;
@@ -4947,10 +4954,10 @@ function drupal_build_js_cache($files) {
 /**
  * Deletes old cached JavaScript files and variables.
  */
-function drupal_clear_js_cache() {
+function clear_js_cache() {
   variable_del('javascript_parsed');
   variable_del('drupal_js_cache_files');
-  file_scan_directory('public://js', '/.*/', array('callback' => 'drupal_delete_file_if_stale'));
+  file_scan_directory('public://js', '/.*/', array('callback' => 'delete_file_if_stale'));
 }
 
 /**
@@ -4985,9 +4992,9 @@ function drupal_json_decode($var) {
  * @param $var
  *   (optional) If set, the variable will be converted to JSON and output.
  */
-function drupal_json_output($var = NULL) {
+function json_output($var = NULL) {
   // We are returning JSON, so tell the browser.
-  drupal_add_http_header('Content-Type', 'application/json');
+  add_http_header('Content-Type', 'application/json');
 
   if (isset($var)) {
     echo drupal_json_encode($var);
@@ -5000,11 +5007,11 @@ function drupal_json_output($var = NULL) {
  * @return
  *   A salt based on information in settings.php, not in the database.
  */
-function drupal_get_hash_salt() {
-  global $drupal_hash_salt, $databases;
-  // If the $drupal_hash_salt variable is empty, a hash of the serialized
+function get_hash_salt() {
+  global $hash_salt, $databases;
+  // If the $hash_salt variable is empty, a hash of the serialized
   // database credentials is used as a fallback salt.
-  return empty($drupal_hash_salt) ? hash('sha256', serialize($databases)) : $drupal_hash_salt;
+  return empty($hash_salt) ? hash('sha256', serialize($databases)) : $hash_salt;
 }
 
 /**
@@ -5013,9 +5020,9 @@ function drupal_get_hash_salt() {
  * @return
  *   The private key.
  */
-function drupal_get_private_key() {
+function get_private_key() {
   if (!($key = variable_get('drupal_private_key', 0))) {
-    $key = drupal_hash_base64(drupal_random_bytes(55));
+    $key = hash_base64(random_bytes(55));
     variable_set('drupal_private_key', $key);
   }
   return $key;
@@ -5027,8 +5034,8 @@ function drupal_get_private_key() {
  * @param $value
  *   An additional value to base the token on.
  */
-function drupal_get_token($value = '') {
-  return drupal_hmac_base64($value, session_id() . drupal_get_private_key() . drupal_get_hash_salt());
+function get_token($value = '') {
+  return hmac_base64($value, session_id() . get_private_key() . get_hash_salt());
 }
 
 /**
@@ -5045,32 +5052,32 @@ function drupal_get_token($value = '') {
  *   True for a valid token, false for an invalid token. When $skip_anonymous
  *   is true, the return value will always be true for anonymous users.
  */
-function drupal_valid_token($token, $value = '', $skip_anonymous = FALSE) {
+function valid_token($token, $value = '', $skip_anonymous = FALSE) {
   global $user;
-  return (($skip_anonymous && $user->uid == 0) || ($token == drupal_get_token($value)));
+  return (($skip_anonymous && $user->uid == 0) || ($token == get_token($value)));
 }
 
-function _drupal_bootstrap_full() {
+function _bootstrap_full() {
   static $called = FALSE;
 
   if ($called) {
     return;
   }
   $called = TRUE;
-  require_once DRUPAL_ROOT . '/' . variable_get('path_inc', 'core/includes/path.inc');
-  require_once DRUPAL_ROOT . '/core/includes/theme.inc';
-  require_once DRUPAL_ROOT . '/core/includes/pager.inc';
-  require_once DRUPAL_ROOT . '/' . variable_get('menu_inc', 'core/includes/menu.inc');
-  require_once DRUPAL_ROOT . '/core/includes/tablesort.inc';
-  require_once DRUPAL_ROOT . '/core/includes/file.inc';
-  require_once DRUPAL_ROOT . '/core/includes/unicode.inc';
-  require_once DRUPAL_ROOT . '/core/includes/image.inc';
-  require_once DRUPAL_ROOT . '/core/includes/form.inc';
-  require_once DRUPAL_ROOT . '/core/includes/mail.inc';
-  require_once DRUPAL_ROOT . '/core/includes/actions.inc';
-  require_once DRUPAL_ROOT . '/core/includes/ajax.inc';
-  require_once DRUPAL_ROOT . '/core/includes/token.inc';
-  require_once DRUPAL_ROOT . '/core/includes/errors.inc';
+  require_once ROOT . '/' . variable_get('path_inc', 'core/includes/path.inc');
+  require_once ROOT . '/core/includes/theme.inc';
+  require_once ROOT . '/core/includes/pager.inc';
+  require_once ROOT . '/' . variable_get('menu_inc', 'core/includes/menu.inc');
+  require_once ROOT . '/core/includes/tablesort.inc';
+  require_once ROOT . '/core/includes/file.inc';
+  require_once ROOT . '/core/includes/unicode.inc';
+  require_once ROOT . '/core/includes/image.inc';
+  require_once ROOT . '/core/includes/form.inc';
+  require_once ROOT . '/core/includes/mail.inc';
+  require_once ROOT . '/core/includes/actions.inc';
+  require_once ROOT . '/core/includes/ajax.inc';
+  require_once ROOT . '/core/includes/token.inc';
+  require_once ROOT . '/core/includes/errors.inc';
 
   // Detect string handling method
   unicode_check();
@@ -5081,7 +5088,7 @@ function _drupal_bootstrap_full() {
   // Make sure all stream wrappers are registered.
   file_get_stream_wrappers();
 
-  $test_info = &$GLOBALS['drupal_test_info'];
+  $test_info = &$GLOBALS['test_info'];
   if (!empty($test_info['in_child_site'])) {
     // Running inside the simpletest child site, log fatal errors to test
     // specific file directory.
@@ -5090,7 +5097,7 @@ function _drupal_bootstrap_full() {
   }
 
   // Initialize $_GET['q'] prior to invoking hook_init().
-  drupal_path_initialize();
+  path_initialize();
 
   // Let all modules take action before the menu system handles the request.
   // We do not want this while running update.php.
@@ -5103,7 +5110,7 @@ function _drupal_bootstrap_full() {
     //   (e.g., hook_form_alter(), hook_node_view_alter(), hook_page_alter()),
     //   ahead of when rendering starts.
     menu_set_custom_theme();
-    drupal_theme_initialize();
+    theme_initialize();
     module_invoke_all('init');
   }
 }
@@ -5119,18 +5126,18 @@ function _drupal_bootstrap_full() {
  * Page compression requires the PHP zlib extension
  * (http://php.net/manual/en/ref.zlib.php).
  *
- * @see drupal_page_header()
+ * @see page_header()
  */
-function drupal_page_set_cache() {
+function page_set_cache() {
   global $base_root;
 
-  if (drupal_page_is_cacheable()) {
+  if (page_is_cacheable()) {
     $cache = (object) array(
       'cid' => $base_root . request_uri(),
       'data' => array(
         'path' => $_GET['q'],
         'body' => ob_get_clean(),
-        'title' => drupal_get_title(),
+        'title' => get_title(),
         'headers' => array(),
       ),
       'expire' => CACHE_TEMPORARY,
@@ -5138,9 +5145,9 @@ function drupal_page_set_cache() {
     );
 
     // Restore preferred header names based on the lower-case names returned
-    // by drupal_get_http_header().
-    $header_names = _drupal_set_preferred_header_name();
-    foreach (drupal_get_http_header() as $name_lower => $value) {
+    // by get_http_header().
+    $header_names = _set_preferred_header_name();
+    foreach (get_http_header() as $name_lower => $value) {
       $cache->data['headers'][$header_names[$name_lower]] = $value;
       if ($name_lower == 'expires') {
         // Use the actual timestamp from an Expires header if available.
@@ -5166,17 +5173,17 @@ function drupal_page_set_cache() {
  * @return
  *   TRUE if cron ran successfully.
  */
-function drupal_cron_run() {
+function cron_run() {
   // Allow execution to continue even if the request gets canceled.
   @ignore_user_abort(TRUE);
 
   // Prevent session information from being saved while cron is running.
-  drupal_save_session(FALSE);
+  save_session(FALSE);
 
   // Force the current user to anonymous to ensure consistent permissions on
   // cron runs.
   $original_user = $GLOBALS['user'];
-  $GLOBALS['user'] = drupal_anonymous_user();
+  $GLOBALS['user'] = anonymous_user();
 
   // Try to allocate enough time to run all the hook_cron implementations.
   drupal_set_time_limit(240);
@@ -5184,7 +5191,7 @@ function drupal_cron_run() {
   $return = FALSE;
   // Grab the defined cron queues.
   $queues = module_invoke_all('cron_queue_info');
-  drupal_alter('cron_queue_info', $queues);
+  alter('cron_queue_info', $queues);
 
   // Try to acquire cron lock.
   if (!lock_acquire('cron', 240.0)) {
@@ -5195,10 +5202,10 @@ function drupal_cron_run() {
     // Make sure every queue exists. There is no harm in trying to recreate an
     // existing queue.
     foreach ($queues as $queue_name => $info) {
-      DrupalQueue::get($queue_name)->createQueue();
+      Queue::get($queue_name)->createQueue();
     }
     // Register shutdown callback.
-    drupal_register_shutdown_function('drupal_cron_cleanup');
+    drupal_register_shutdown_function('Drupal\cron_cleanup');
 
     // Iterate through the modules calling their cron handlers (if any):
     foreach (module_implements('cron') as $module) {
@@ -5223,9 +5230,9 @@ function drupal_cron_run() {
   }
 
   foreach ($queues as $queue_name => $info) {
-    $function = $info['worker callback'];
+    $function = 'Drupal\\' . $info['worker callback'];
     $end = time() + (isset($info['time']) ? $info['time'] : 15);
-    $queue = DrupalQueue::get($queue_name);
+    $queue = Queue::get($queue_name);
     while (time() < $end && ($item = $queue->claimItem())) {
       $function($item->data);
       $queue->deleteItem($item);
@@ -5233,7 +5240,7 @@ function drupal_cron_run() {
   }
   // Restore the user.
   $GLOBALS['user'] = $original_user;
-  drupal_save_session(TRUE);
+  save_session(TRUE);
 
   return $return;
 }
@@ -5241,10 +5248,10 @@ function drupal_cron_run() {
 /**
  * Shutdown function: Performs cron cleanup.
  *
- * @see drupal_cron_run()
+ * @see cron_run()
  * @see drupal_register_shutdown_function()
  */
-function drupal_cron_cleanup() {
+function cron_cleanup() {
   // See if the semaphore is still locked.
   if (variable_get('cron_semaphore', FALSE)) {
     watchdog('cron', 'Cron run exceeded the time limit and was aborted.', array(), WATCHDOG_WARNING);
@@ -5262,7 +5269,7 @@ function drupal_cron_cleanup() {
  * depending on what type of object you are looking for. For instance, if you
  * are looking for modules and call:
  * @code
- * drupal_system_listing("/\.module$/", "modules", 'name', 0);
+ * system_listing("/\.module$/", "modules", 'name', 0);
  * @endcode
  * this function will search the site-wide modules directory (i.e., /modules/),
  * your install profile's directory (i.e.,
@@ -5303,7 +5310,7 @@ function drupal_cron_cleanup() {
  *   - 'filename': File name.
  *   - 'name': Name of file without the extension.
  */
-function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) {
+function system_listing($mask, $directory, $key = 'name', $min_depth = 1) {
   $config = conf_path();
   $files = array();
 
@@ -5314,7 +5321,7 @@ function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1)
   // themes as provided by a distribution. It is pristine in the same way that
   // the 'core/modules' directory is pristine for core; users should avoid
   // any modification by using the sites/all or sites/<domain> directories.
-  $profile = drupal_get_profile();
+  $profile = get_profile();
   if (file_exists("profiles/$profile/$directory")) {
     $searchdir[] = "profiles/$profile/$directory";
   }
@@ -5327,8 +5334,8 @@ function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1)
   }
 
   // Get current list of items.
-  if (!function_exists('file_scan_directory')) {
-    require_once DRUPAL_ROOT . '/core/includes/file.inc';
+  if (!function_exists('Drupal\file_scan_directory')) {
+    require_once ROOT . '/core/includes/file.inc';
   }
   foreach ($searchdir as $dir) {
     $files_to_add = file_scan_directory($dir, $mask, array('key' => $key, 'min_depth' => $min_depth));
@@ -5345,12 +5352,12 @@ function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1)
       // new resource on the list for merging.
       if (file_exists($info_file = dirname($file->uri) . '/' . $file->name . '.info')) {
         // Get the .info file for the module or theme this file belongs to.
-        $info = drupal_parse_info_file($info_file);
+        $info = parse_info_file($info_file);
 
         // If the module or theme is incompatible with Drupal core, remove it
         // from the array for the current search directory, so it is not
         // overwritten when merged with the $files array.
-        if (isset($info['core']) && $info['core'] != DRUPAL_CORE_COMPATIBILITY) {
+        if (isset($info['core']) && $info['core'] != CORE_COMPATIBILITY) {
           unset($files_to_add[$file_key]);
         }
       }
@@ -5375,7 +5382,7 @@ function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1)
  *   If called without $content, a renderable array representing the body of
  *   the page.
  */
-function drupal_set_page_content($content = NULL) {
+function set_page_content($content = NULL) {
   $content_block = &drupal_static(__FUNCTION__, NULL);
   $main_content_display = &drupal_static('system_main_content_added', FALSE);
 
@@ -5421,7 +5428,7 @@ function drupal_set_page_content($content = NULL) {
  *   The passed-in element with markup for conditional comments potentially
  *   added to '#prefix' and '#suffix'.
  */
-function drupal_pre_render_conditional_comments($elements) {
+function pre_render_conditional_comments($elements) {
   $browsers = isset($elements['#browsers']) ? $elements['#browsers'] : array();
   $browsers += array(
     'IE' => TRUE,
@@ -5482,7 +5489,7 @@ function drupal_pre_render_conditional_comments($elements) {
  * @return
  *   The passed-in elements containing a rendered link in '#markup'.
  */
-function drupal_pre_render_link($element) {
+function pre_render_link($element) {
   // By default, link options to pass to l() are normally set in #options.
   $element += array('#options' => array());
   // However, within the scope of renderable elements, #attributes is a valid
@@ -5508,7 +5515,7 @@ function drupal_pre_render_link($element) {
   if (isset($element['#ajax']) && !isset($element['#ajax_processed'])) {
     // If no HTML ID was found above, automatically create one.
     if (!isset($element['#id'])) {
-      $element['#id'] = $element['#options']['attributes']['id'] = drupal_html_id('ajax-link');
+      $element['#id'] = $element['#options']['attributes']['id'] = html_id('ajax-link');
     }
     // If #ajax['path] was not specified, use the href as Ajax request URL.
     if (!isset($element['#ajax']['path'])) {
@@ -5542,7 +5549,7 @@ function drupal_pre_render_link($element) {
  * @code
  * $node->content['links'] = array(
  *   '#theme' => 'links__node',
- *   '#pre_render' = array('drupal_pre_render_links'),
+ *   '#pre_render' = array('pre_render_links'),
  *   'comment' => array(
  *     '#theme' => 'links__node__comment',
  *     '#links' => array(
@@ -5597,7 +5604,7 @@ function drupal_pre_render_link($element) {
  * children, these child-specific properties are ignored, and only the overall
  * properties of the parent are used.
  */
-function drupal_pre_render_links($element) {
+function pre_render_links($element) {
   $element += array('#links' => array());
   foreach (element_children($element) as $key) {
     $child = &$element[$key];
@@ -5629,7 +5636,7 @@ function drupal_pre_render_links($element) {
  *
  * @see drupal_render()
  */
-function drupal_pre_render_markup($elements) {
+function pre_render_markup($elements) {
   $elements['#children'] = $elements['#markup'];
   return $elements;
 }
@@ -5648,31 +5655,31 @@ function drupal_pre_render_markup($elements) {
  * @see hook_page_alter()
  * @see element_info()
  */
-function drupal_render_page($page) {
+function render_page($page) {
   $main_content_display = &drupal_static('system_main_content_added', FALSE);
 
   // Allow menu callbacks to return strings or arbitrary arrays to render.
   // If the array returned is not of #type page directly, we need to fill
   // in the page with defaults.
   if (is_string($page) || (is_array($page) && (!isset($page['#type']) || ($page['#type'] != 'page')))) {
-    drupal_set_page_content($page);
+    set_page_content($page);
     $page = element_info('page');
   }
 
   // Modules can add elements to $page as needed in hook_page_build().
   foreach (module_implements('page_build') as $module) {
-    $function = $module . '_page_build';
+    $function = 'Drupal\\' . $module . '_page_build';
     $function($page);
   }
   // Modules alter the $page as needed. Blocks are populated into regions like
   // 'sidebar_first', 'footer', etc.
-  drupal_alter('page', $page);
+  alter('page', $page);
 
   // If no module has taken care of the main content, add it to the page now.
   // This allows the site to still be usable even if no modules that
   // control page regions (for example, the Block module) are enabled.
   if (!$main_content_display) {
-    $page['content']['system_main'] = drupal_set_page_content();
+    $page['content']['system_main'] = set_page_content();
   }
 
   return drupal_render($page);
@@ -5700,7 +5707,7 @@ function drupal_render_page($page) {
  * these children. For elements that are not allowed to have any children,
  * e.g. buttons or textfields, the theme function can be used to render the
  * element itself. If #theme is not present and the element has children, they
- * are rendered and concatenated into a string by drupal_render_children().
+ * are rendered and concatenated into a string by render_children().
  *
  * The #theme_wrappers property contains an array of theme functions which will
  * be called, in order, after #theme has run. These can be used to add further
@@ -5722,11 +5729,11 @@ function drupal_render_page($page) {
  * property to an associative array with one or several of the following keys:
  * - 'keys': An array of one or more keys that identify the element. If 'keys'
  *   is set, the cache ID is created automatically from these keys. See
- *   drupal_render_cid_create().
+ *   render_cid_create().
  * - 'granularity' (optional): Define the cache granularity using binary
  *   combinations of the cache granularity constants, e.g.
- *   DRUPAL_CACHE_PER_USER to cache for each user separately or
- *   DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE to cache separately for each
+ *   CACHE_PER_USER to cache for each user separately or
+ *   CACHE_PER_PAGE | CACHE_PER_ROLE to cache separately for each
  *   page and role. If not specified the element is cached globally for each
  *   theme and language.
  * - 'cid': Specify the cache ID directly. Either 'keys' or 'cid' is required.
@@ -5736,7 +5743,7 @@ function drupal_render_page($page) {
  * - 'bin': Specify a cache bin to cache the element in. Defaults to 'cache'.
  *
  * This function is usually called from within another function, like
- * drupal_get_form() or a theme function. Elements are sorted internally
+ * get_form() or a theme function. Elements are sorted internally
  * using uasort(). Since this is expensive, when passing already sorted
  * elements to drupal_render(), for example from a database query, set
  * $elements['#sorted'] = TRUE to avoid sorting them a second time.
@@ -5767,7 +5774,7 @@ function drupal_render(&$elements) {
 
   // Try to fetch the element's markup from cache and return.
   if (isset($elements['#cache'])) {
-    $cached_output = drupal_render_cache_get($elements);
+    $cached_output = render_cache_get($elements);
     if ($cached_output !== FALSE) {
       return $cached_output;
     }
@@ -5790,6 +5797,7 @@ function drupal_render(&$elements) {
   // element is rendered into the final text.
   if (isset($elements['#pre_render'])) {
     foreach ($elements['#pre_render'] as $function) {
+      $function = 'Drupal\\' . $function;
       $elements = $function($elements);
     }
   }
@@ -5813,7 +5821,7 @@ function drupal_render(&$elements) {
     $elements['#children'] = theme($elements['#theme'], $elements);
   }
   // If #theme was not set and the element has children, render them now.
-  // This is the same process as drupal_render_children() but is inlined
+  // This is the same process as render_children() but is inlined
   // for speed.
   if ($elements['#children'] == '') {
     foreach ($children as $key) {
@@ -5834,19 +5842,20 @@ function drupal_render(&$elements) {
   // which allows the output'ed text to be filtered.
   if (isset($elements['#post_render'])) {
     foreach ($elements['#post_render'] as $function) {
+      $function = 'Drupal\\' . $function;
       $elements['#children'] = $function($elements['#children'], $elements);
     }
   }
 
   // Add any JavaScript state information associated with the element.
   if (!empty($elements['#states'])) {
-    drupal_process_states($elements);
+    process_states($elements);
   }
 
   // Add additional libraries, CSS, JavaScript an other custom
   // attached data associated with this element.
   if (!empty($elements['#attached'])) {
-    drupal_process_attached($elements);
+    process_attached($elements);
   }
 
   $prefix = isset($elements['#prefix']) ? $elements['#prefix'] : '';
@@ -5855,7 +5864,7 @@ function drupal_render(&$elements) {
 
   // Cache the processed element if #cache is set.
   if (isset($elements['#cache'])) {
-    drupal_render_cache_set($output, $elements);
+    render_cache_set($output, $elements);
   }
 
   $elements['#printed'] = TRUE;
@@ -5874,7 +5883,7 @@ function drupal_render(&$elements) {
  *   If the keys of the element's children are already known, they can be passed
  *   in to save another run of element_children().
  */
-function drupal_render_children(&$element, $children_keys = NULL) {
+function render_children(&$element, $children_keys = NULL) {
   if ($children_keys === NULL) {
     $children_keys = element_children($element);
   }
@@ -5982,10 +5991,10 @@ function show(&$element) {
  *   if no cached copy of the element is available.
  *
  * @see drupal_render()
- * @see drupal_render_cache_set()
+ * @see render_cache_set()
  */
-function drupal_render_cache_get($elements) {
-  if (!in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) || !$cid = drupal_render_cid_create($elements)) {
+function render_cache_get($elements) {
+  if (!in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) || !$cid = render_cid_create($elements)) {
     return FALSE;
   }
   $bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache';
@@ -5994,7 +6003,7 @@ function drupal_render_cache_get($elements) {
     // Add additional libraries, JavaScript, CSS and other data attached
     // to this element.
     if (isset($cache->data['#attached'])) {
-      drupal_process_attached($cache->data);
+      process_attached($cache->data);
     }
     // Return the rendered output.
     return $cache->data['#markup'];
@@ -6013,11 +6022,11 @@ function drupal_render_cache_get($elements) {
  * @param $elements
  *   A renderable array.
  *
- * @see drupal_render_cache_get()
+ * @see render_cache_get()
  */
-function drupal_render_cache_set(&$markup, $elements) {
+function render_cache_set(&$markup, $elements) {
   // Create the cache ID for the element.
-  if (!in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) || !$cid = drupal_render_cid_create($elements)) {
+  if (!in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) || !$cid = render_cid_create($elements)) {
     return FALSE;
   }
 
@@ -6029,7 +6038,7 @@ function drupal_render_cache_set(&$markup, $elements) {
   // be retrieved and used.
   $data['#markup'] = &$markup;
   // Persist attached data associated with this element.
-  $attached = drupal_render_collect_attached($elements, TRUE);
+  $attached = render_collect_attached($elements, TRUE);
   if ($attached) {
     $data['#attached'] = $attached;
   }
@@ -6054,7 +6063,7 @@ function drupal_render_cache_set(&$markup, $elements) {
  * @return
  *   The #attached array for this element and its descendants.
  */
-function drupal_render_collect_attached($elements, $return = FALSE) {
+function render_collect_attached($elements, $return = FALSE) {
   $attached = &drupal_static(__FUNCTION__, array());
 
   // Collect all #attached for this element.
@@ -6068,7 +6077,7 @@ function drupal_render_collect_attached($elements, $return = FALSE) {
   }
   if ($children = element_children($elements)) {
     foreach ($children as $child) {
-      drupal_render_collect_attached($elements[$child]);
+      render_collect_attached($elements[$child]);
     }
   }
 
@@ -6096,20 +6105,20 @@ function drupal_render_collect_attached($elements, $return = FALSE) {
  * @param $function
  *   The name of the function doing this caching. A _pre_render suffix will be
  *   added to this string and is also part of the cache key in
- *   drupal_render_cache_set() and drupal_render_cache_get().
+ *   render_cache_set() and render_cache_get().
  * @param $expire
  *   The cache expire time, passed eventually to cache()->set().
  * @param $granularity
- *   One or more granularity constants passed to drupal_render_cid_parts().
+ *   One or more granularity constants passed to render_cid_parts().
  *
  * @return
  *   A renderable array with the following keys and values:
  *   - #query: The passed-in $query.
  *   - #pre_render: $function with a _pre_render suffix.
- *   - #cache: An associative array prepared for drupal_render_cache_set().
+ *   - #cache: An associative array prepared for render_cache_set().
  */
-function drupal_render_cache_by_query($query, $function, $expire = CACHE_TEMPORARY, $granularity = NULL) {
-  $cache_keys = array_merge(array($function), drupal_render_cid_parts($granularity));
+function render_cache_by_query($query, $function, $expire = CACHE_TEMPORARY, $granularity = NULL) {
+  $cache_keys = array_merge(array($function), render_cid_parts($granularity));
   $query->preExecute();
   $cache_keys[] = hash('sha256', serialize(array((string) $query, $query->getArguments())));
   return array(
@@ -6127,10 +6136,10 @@ function drupal_render_cache_by_query($query, $function, $expire = CACHE_TEMPORA
  *
  * @param $granularity
  *   One or more cache granularity constants. For example, to cache separately
- *   for each user, use DRUPAL_CACHE_PER_USER. To cache separately for each
+ *   for each user, use CACHE_PER_USER. To cache separately for each
  *   page and role, use the expression:
  *   @code
- *   DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE
+ *   CACHE_PER_PAGE | CACHE_PER_ROLE
  *   @endcode
  *
  * @return
@@ -6138,7 +6147,7 @@ function drupal_render_cache_by_query($query, $function, $expire = CACHE_TEMPORA
  *   locale module is enabled it also contains the active language. If
  *   $granularity was passed in, more parts are added.
  */
-function drupal_render_cid_parts($granularity = NULL) {
+function render_cid_parts($granularity = NULL) {
   global $theme, $base_root, $user;
 
   $cid_parts[] = $theme;
@@ -6154,14 +6163,14 @@ function drupal_render_cid_parts($granularity = NULL) {
     // 'PER_ROLE' and 'PER_USER' are mutually exclusive. 'PER_USER' can be a
     // resource drag for sites with many users, so when a module is being
     // equivocal, we favor the less expensive 'PER_ROLE' pattern.
-    if ($granularity & DRUPAL_CACHE_PER_ROLE) {
+    if ($granularity & CACHE_PER_ROLE) {
       $cid_parts[] = 'r.' . implode(',', array_keys($user->roles));
     }
-    elseif ($granularity & DRUPAL_CACHE_PER_USER) {
+    elseif ($granularity & CACHE_PER_USER) {
       $cid_parts[] = "u.$user->uid";
     }
 
-    if ($granularity & DRUPAL_CACHE_PER_PAGE) {
+    if ($granularity & CACHE_PER_PAGE) {
       $cid_parts[] = $base_root . request_uri();
     }
   }
@@ -6182,14 +6191,14 @@ function drupal_render_cid_parts($granularity = NULL) {
  * @return
  *   The cache ID string, or FALSE if the element may not be cached.
  */
-function drupal_render_cid_create($elements) {
+function render_cid_create($elements) {
   if (isset($elements['#cache']['cid'])) {
     return $elements['#cache']['cid'];
   }
   elseif (isset($elements['#cache']['keys'])) {
     $granularity = isset($elements['#cache']['granularity']) ? $elements['#cache']['granularity'] : NULL;
-    // Merge in additional cache ID parts based provided by drupal_render_cid_parts().
-    $cid_parts = array_merge($elements['#cache']['keys'], drupal_render_cid_parts($granularity));
+    // Merge in additional cache ID parts based provided by render_cid_parts().
+    $cid_parts = array_merge($elements['#cache']['keys'], render_cid_parts($granularity));
     return implode(':', $cid_parts);
   }
   return FALSE;
@@ -6242,11 +6251,11 @@ function element_sort_by_title($a, $b) {
  */
 function element_info($type) {
   // Use the advanced drupal_static() pattern, since this is called very often.
-  static $drupal_static_fast;
-  if (!isset($drupal_static_fast)) {
-    $drupal_static_fast['cache'] = &drupal_static(__FUNCTION__);
+  static $static_fast;
+  if (!isset($static_fast)) {
+    $static_fast['cache'] = &drupal_static(__FUNCTION__);
   }
-  $cache = &$drupal_static_fast['cache'];
+  $cache = &$static_fast['cache'];
 
   if (!isset($cache)) {
     $cache = module_invoke_all('element_info');
@@ -6254,7 +6263,7 @@ function element_info($type) {
       $cache[$element_type]['#type'] = $element_type;
     }
     // Allow modules to alter the element type defaults.
-    drupal_alter('element_info', $cache);
+    alter('element_info', $cache);
   }
 
   return isset($cache[$type]) ? $cache[$type] : array();
@@ -6282,8 +6291,8 @@ function element_info_property($type, $property_name, $default = NULL) {
  * - _field_ui_reduce_order()
  * - update_resolve_dependencies()
  * - archiver_get_info()
- * - drupal_get_updaters()
- * - drupal_get_filetransfer_info()
+ * - get_updaters()
+ * - get_filetransfer_info()
  *
  * @param $a
  *   First item for comparison. The compared items should be associative arrays
@@ -6291,7 +6300,7 @@ function element_info_property($type, $property_name, $default = NULL) {
  * @param $b
  *   Second item for comparison.
  */
-function drupal_sort_weight($a, $b) {
+function sort_weight($a, $b) {
   $a_weight = (is_array($a) && isset($a['weight'])) ? $a['weight'] : 0;
   $b_weight = (is_array($b) && isset($b['weight'])) ? $b['weight'] : 0;
   if ($a_weight == $b_weight) {
@@ -6311,7 +6320,7 @@ function drupal_sort_weight($a, $b) {
  * @param $b
  *   Second item for comparison.
  */
-function drupal_sort_title($a, $b) {
+function sort_title($a, $b) {
   if (!isset($b['title'])) {
     return -1;
   }
@@ -6332,7 +6341,7 @@ function element_property($key) {
  * Gets properties of a structured array element (keys beginning with '#').
  */
 function element_properties($element) {
-  return array_filter(array_keys((array) $element), 'element_property');
+  return array_filter(array_keys((array) $element), 'Drupal\element_property');
 }
 
 /**
@@ -6380,7 +6389,7 @@ function element_children(&$elements, $sort = FALSE) {
   }
   // Sort the children if necessary.
   if ($sort && $sortable) {
-    uasort($children, 'element_sort');
+    uasort($children, 'Drupal\element_sort');
     // Put the sorted children back into $elements in the correct order, to
     // preserve sorting if the same element is passed through
     // element_children() twice.
@@ -6467,7 +6476,7 @@ function element_set_attributes(array &$element, array $map) {
  *
  * Instead, use this helper function:
  * @code
- * $value = drupal_array_get_nested_value($form, $parents);
+ * $value = array_get_nested_value($form, $parents);
  * @endcode
  *
  * The return value will be NULL, regardless of whether the actual value is NULL
@@ -6476,7 +6485,7 @@ function element_set_attributes(array &$element, array $map) {
  * altered by reference:
  * @code
  * $key_exists = NULL;
- * $value = drupal_array_get_nested_value($form, $parents, $key_exists);
+ * $value = array_get_nested_value($form, $parents, $key_exists);
  * if ($key_exists) {
  *   // ... do something with $value ...
  * }
@@ -6503,10 +6512,10 @@ function element_set_attributes(array &$element, array $map) {
  *   (FALSE). This allows to distinguish between the two possibilities when NULL
  *   is returned.
  *
- * @see drupal_array_set_nested_value()
- * @see drupal_array_unset_nested_value()
+ * @see array_set_nested_value()
+ * @see array_unset_nested_value()
  */
-function &drupal_array_get_nested_value(array &$array, array $parents, &$key_exists = NULL) {
+function &array_get_nested_value(array &$array, array $parents, &$key_exists = NULL) {
   $ref = &$array;
   foreach ($parents as $parent) {
     if (is_array($ref) && array_key_exists($parent, $ref)) {
@@ -6558,7 +6567,7 @@ function &drupal_array_get_nested_value(array &$array, array $parents, &$key_exi
  *
  * Instead, use this helper function:
  * @code
- * drupal_array_set_nested_value($form, $parents, $element);
+ * array_set_nested_value($form, $parents, $element);
  * @endcode
  *
  * However if the number of array parent keys is static, the value should always
@@ -6580,10 +6589,10 @@ function &drupal_array_get_nested_value(array &$array, array $parents, &$key_exi
  *   FALSE, PHP throws an error if trying to add into a value that is not an
  *   array. Defaults to FALSE.
  *
- * @see drupal_array_unset_nested_value()
- * @see drupal_array_get_nested_value()
+ * @see array_unset_nested_value()
+ * @see array_get_nested_value()
  */
-function drupal_array_set_nested_value(array &$array, array $parents, $value, $force = FALSE) {
+function array_set_nested_value(array &$array, array $parents, $value, $force = FALSE) {
   $ref = &$array;
   foreach ($parents as $parent) {
     // PHP auto-creates container arrays and NULL entries without error if $ref
@@ -6632,7 +6641,7 @@ function drupal_array_set_nested_value(array &$array, array $parents, $value, $f
  *
  * Instead, use this helper function:
  * @code
- * drupal_array_unset_nested_value($form, $parents, $element);
+ * array_unset_nested_value($form, $parents, $element);
  * @endcode
  *
  * However if the number of array parent keys is static, the value should always
@@ -6651,12 +6660,12 @@ function drupal_array_set_nested_value(array &$array, array $parents, $value, $f
  *   (optional) If given, an already defined variable that is altered by
  *   reference.
  *
- * @see drupal_array_set_nested_value()
- * @see drupal_array_get_nested_value()
+ * @see array_set_nested_value()
+ * @see array_get_nested_value()
  */
-function drupal_array_unset_nested_value(array &$array, array $parents, &$key_existed = NULL) {
+function array_unset_nested_value(array &$array, array $parents, &$key_existed = NULL) {
   $unset_key = array_pop($parents);
-  $ref = &drupal_array_get_nested_value($array, $parents, $key_existed);
+  $ref = &array_get_nested_value($array, $parents, $key_existed);
   if ($key_existed && is_array($ref) && array_key_exists($unset_key, $ref)) {
     $key_existed = TRUE;
     unset($ref[$unset_key]);
@@ -6671,11 +6680,11 @@ function drupal_array_unset_nested_value(array &$array, array $parents, &$key_ex
  *
  * This helper function should be used when the depth of the array element to be
  * checked may vary (that is, the number of parent keys is variable). See
- * drupal_array_set_nested_value() for details. It is primarily used for form
+ * array_set_nested_value() for details. It is primarily used for form
  * structures and renderable arrays.
  *
  * If it is required to also get the value of the checked nested key, use
- * drupal_array_get_nested_value() instead.
+ * array_get_nested_value() instead.
  *
  * If the number of array parent keys is static, this helper function is
  * unnecessary and the following code can be used instead:
@@ -6692,20 +6701,20 @@ function drupal_array_unset_nested_value(array &$array, array $parents, &$key_ex
  * @return
  *   TRUE if all the parent keys exist, FALSE otherwise.
  *
- * @see drupal_array_get_nested_value()
+ * @see array_get_nested_value()
  */
-function drupal_array_nested_key_exists(array $array, array $parents) {
+function array_nested_key_exists(array $array, array $parents) {
   // Although this function is similar to PHP's array_key_exists(), its
-  // arguments should be consistent with drupal_array_get_nested_value().
+  // arguments should be consistent with array_get_nested_value().
   $key_exists = NULL;
-  drupal_array_get_nested_value($array, $parents, $key_exists);
+  array_get_nested_value($array, $parents, $key_exists);
   return $key_exists;
 }
 
 /**
  * Provides theme registration for themes across .inc files.
  */
-function drupal_common_theme() {
+function common_theme() {
   return array(
     // From theme.inc.
     'html' => array(
@@ -6923,9 +6932,9 @@ function drupal_common_theme() {
  * @param $module
  *   The module for which the tables will be created.
  */
-function drupal_install_schema($module) {
-  $schema = drupal_get_schema_unprocessed($module);
-  _drupal_schema_initialize($schema, $module, FALSE);
+function install_schema($module) {
+  $schema = get_schema_unprocessed($module);
+  _schema_initialize($schema, $module, FALSE);
 
   foreach ($schema as $name => $table) {
     db_create_table($name, $table);
@@ -6947,9 +6956,9 @@ function drupal_install_schema($module) {
  *    - success: a boolean indicating whether the query succeeded.
  *    - query: the SQL query(s) executed, passed through check_plain().
  */
-function drupal_uninstall_schema($module) {
-  $schema = drupal_get_schema_unprocessed($module);
-  _drupal_schema_initialize($schema, $module, FALSE);
+function uninstall_schema($module) {
+  $schema = get_schema_unprocessed($module);
+  _schema_initialize($schema, $module, FALSE);
 
   foreach ($schema as $table) {
     if (db_table_exists($table['name'])) {
@@ -6971,8 +6980,8 @@ function drupal_uninstall_schema($module) {
  * hook_schema(), so it allows you to derive your tables from existing
  * specifications.
  *
- * It is also used by drupal_install_schema() and
- * drupal_uninstall_schema() to ensure that a module's tables are
+ * It is also used by install_schema() and
+ * uninstall_schema() to ensure that a module's tables are
  * created exactly as specified without any changes introduced by a
  * module that implements hook_schema_alter().
  *
@@ -6982,7 +6991,7 @@ function drupal_uninstall_schema($module) {
  *   The name of the table. If not given, the module's complete schema
  *   is returned.
  */
-function drupal_get_schema_unprocessed($module, $table = NULL) {
+function get_schema_unprocessed($module, $table = NULL) {
   // Load the .install file to get hook_schema.
   module_load_install($module);
   $schema = module_invoke($module, 'schema');
@@ -7009,7 +7018,7 @@ function drupal_get_schema_unprocessed($module, $table = NULL) {
  *   and fields to improve performance of serialize() and unserialize().
  *   Defaults to TRUE.
  */
-function _drupal_schema_initialize(&$schema, $module, $remove_descriptions = TRUE) {
+function _schema_initialize(&$schema, $module, $remove_descriptions = TRUE) {
   // Set the name and module key for all tables.
   foreach ($schema as $name => &$table) {
     if (empty($table['module'])) {
@@ -7039,8 +7048,8 @@ function _drupal_schema_initialize(&$schema, $module, $remove_descriptions = TRU
  *
  * @return An array of fields.
  */
-function drupal_schema_fields_sql($table, $prefix = NULL) {
-  $schema = drupal_get_schema($table);
+function schema_fields_sql($table, $prefix = NULL) {
+  $schema = get_schema($table);
   $fields = array_keys($schema['fields']);
   if ($prefix) {
     $columns = array();
@@ -7077,13 +7086,13 @@ function drupal_schema_fields_sql($table, $prefix = NULL) {
  *   If the record insert or update failed, returns FALSE. If it succeeded,
  *   returns SAVED_NEW or SAVED_UPDATED, depending on the operation performed.
  */
-function drupal_write_record($table, &$record, $primary_keys = array()) {
+function write_record($table, &$record, $primary_keys = array()) {
   // Standardize $primary_keys to an array.
   if (is_string($primary_keys)) {
     $primary_keys = array($primary_keys);
   }
 
-  $schema = drupal_get_schema($table);
+  $schema = get_schema($table);
   if (empty($schema)) {
     return FALSE;
   }
@@ -7252,9 +7261,9 @@ function drupal_write_record($table, &$record, $primary_keys = array()) {
  * @return
  *   The info array.
  *
- * @see drupal_parse_info_format()
+ * @see parse_info_format()
  */
-function drupal_parse_info_file($filename) {
+function parse_info_file($filename) {
   $info = &drupal_static(__FUNCTION__, array());
 
   if (!isset($info[$filename])) {
@@ -7263,7 +7272,7 @@ function drupal_parse_info_file($filename) {
     }
     else {
       $data = file_get_contents($filename);
-      $info[$filename] = drupal_parse_info_format($data);
+      $info[$filename] = parse_info_format($data);
     }
   }
   return $info[$filename];
@@ -7304,9 +7313,9 @@ function drupal_parse_info_file($filename) {
  * @return
  *   The info array.
  *
- * @see drupal_parse_info_file()
+ * @see parse_info_file()
  */
-function drupal_parse_info_format($data) {
+function parse_info_format($data) {
   $info = array();
   $constants = get_defined_constants();
 
@@ -7347,9 +7356,9 @@ function drupal_parse_info_format($data) {
         $parent = &$parent[$key];
       }
 
-      // Handle PHP constants.
-      if (isset($constants[$value])) {
-        $value = $constants[$value];
+      // Handle PHP constants. Namespaces are lowercase in this array.
+      if (isset($constants['drupal\\' . $value])) {
+        $value = $constants['drupal\\' . $value];
       }
 
       // Insert actual value.
@@ -7390,9 +7399,9 @@ function watchdog_severity_levels() {
 /**
  * Explodes a string of tags into an array.
  *
- * @see drupal_implode_tags()
+ * @see implode_tags()
  */
-function drupal_explode_tags($tags) {
+function explode_tags($tags) {
   // This regexp allows the following types of user input:
   // this, "somecompany, llc", "and ""this"" w,o.rks", foo bar
   $regexp = '%(?:^|,\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x';
@@ -7416,9 +7425,9 @@ function drupal_explode_tags($tags) {
 /**
  * Implodes an array of tags into a string.
  *
- * @see drupal_explode_tags()
+ * @see explode_tags()
  */
-function drupal_implode_tags($tags) {
+function implode_tags($tags) {
   $encoded_tags = array();
   foreach ($tags as $tag) {
     // Commas and quotes in tag names are special cases, so encode them.
@@ -7437,18 +7446,18 @@ function drupal_implode_tags($tags) {
  * Empties cache tables, rebuilds the menu cache and theme registries, and
  * invokes a hook so that other modules' cache data can be cleared as well.
  */
-function drupal_flush_all_caches() {
+function flush_all_caches() {
   // Change query-strings on css/js files to enforce reload for all users.
-  _drupal_flush_css_js();
+  _flush_css_js();
 
   registry_rebuild();
-  drupal_clear_css_cache();
-  drupal_clear_js_cache();
+  clear_css_cache();
+  clear_js_cache();
 
   // Rebuild the theme data. Note that the module data is rebuilt above, as
   // part of registry_rebuild().
   system_rebuild_theme_data();
-  drupal_theme_rebuild();
+  theme_rebuild();
 
   entity_info_cache_clear();
 
@@ -7484,7 +7493,7 @@ function drupal_flush_all_caches() {
  * Changing the dummy query string appended to CSS and JavaScript files forces
  * all browsers to reload fresh files.
  */
-function _drupal_flush_css_js() {
+function _flush_css_js() {
   // The timestamp is converted to base 36 in order to make it more compact.
   variable_set('css_js_query_string', base_convert(REQUEST_TIME, 10, 36));
 }
@@ -7515,7 +7524,7 @@ function debug($data, $label = NULL, $print_r = FALSE) {
 }
 
 /**
- * Parses a dependency for comparison by drupal_check_incompatibility().
+ * Parses a dependency for comparison by check_incompatibility().
  *
  * @param $dependency
  *   A dependency string, for example 'foo (>=8.x-4.5-beta5, 3.x)'.
@@ -7528,16 +7537,16 @@ function debug($data, $label = NULL, $print_r = FALSE) {
  *   - 'versions' is a list of associative arrays, each containing the keys
  *     'op' and 'version'. 'op' can be one of: '=', '==', '!=', '<>', '<',
  *     '<=', '>', or '>='. 'version' is one piece like '4.5-beta3'.
- *   Callers should pass this structure to drupal_check_incompatibility().
+ *   Callers should pass this structure to check_incompatibility().
  *
- * @see drupal_check_incompatibility()
+ * @see check_incompatibility()
  */
-function drupal_parse_dependency($dependency) {
+function parse_dependency($dependency) {
   // We use named subpatterns and support every op that version_compare
   // supports. Also, op is optional and defaults to equals.
   $p_op = '(?P<operation>!=|==|=|<|<=|>|>=|<>)?';
   // Core version is always optional: 8.x-2.x and 2.x is treated the same.
-  $p_core = '(?:' . preg_quote(DRUPAL_CORE_COMPATIBILITY) . '-)?';
+  $p_core = '(?:' . preg_quote(CORE_COMPATIBILITY) . '-)?';
   $p_major = '(?P<major>\d+)';
   // By setting the minor version to x, branches can be matched.
   $p_minor = '(?P<minor>(?:\d+|x)(?:-[A-Za-z]+\d+)?)';
@@ -7576,7 +7585,7 @@ function drupal_parse_dependency($dependency) {
  * Checks whether a version is compatible with a given dependency.
  *
  * @param $v
- *   The parsed dependency structure from drupal_parse_dependency().
+ *   The parsed dependency structure from parse_dependency().
  * @param $current_version
  *   The version to check against (like 4.2).
  *
@@ -7584,9 +7593,9 @@ function drupal_parse_dependency($dependency) {
  *   NULL if compatible, otherwise the original dependency version string that
  *   caused the incompatibility.
  *
- * @see drupal_parse_dependency()
+ * @see parse_dependency()
  */
-function drupal_check_incompatibility($v, $current_version) {
+function check_incompatibility($v, $current_version) {
   if (!empty($v['versions'])) {
     foreach ($v['versions'] as $required_version) {
       if ((isset($required_version['op']) && !version_compare($current_version, $required_version['version'], $required_version['op']))) {
@@ -7613,7 +7622,7 @@ function drupal_check_incompatibility($v, $current_version) {
  *   are the arguments to pass to the respective method. If multiple methods
  *   are specified, a system.multicall is performed.
  * @param $options
- *   (optional) An array of options to pass along to drupal_http_request().
+ *   (optional) An array of options to pass along to http_request().
  *
  * @return
  *   For one request:
@@ -7625,7 +7634,7 @@ function drupal_check_incompatibility($v, $current_version) {
  *     failed. See xmlrpc_error().
  */
 function xmlrpc($url, $args, $options = array()) {
-  require_once DRUPAL_ROOT . '/core/includes/xmlrpc.inc';
+  require_once ROOT . '/core/includes/xmlrpc.inc';
   return _xmlrpc($url, $args, $options);
 }
 
@@ -7643,8 +7652,8 @@ function archiver_get_info() {
     if ($cache === FALSE) {
       // Rebuild the cache and save it.
       $archiver_info = module_invoke_all('archiver_info');
-      drupal_alter('archiver_info', $archiver_info);
-      uasort($archiver_info, 'drupal_sort_weight');
+      alter('archiver_info', $archiver_info);
+      uasort($archiver_info, 'Drupal\sort_weight');
       cache()->set('archiver_info', $archiver_info);
     }
     else {
@@ -7704,7 +7713,8 @@ function archiver_get_archiver($file) {
       // Also note that the file may not yet exist, so we cannot rely
       // on fileinfo() or other disk-level utilities.
       if (strrpos($filepath, '.' . $extension) === strlen($filepath) - strlen('.' . $extension)) {
-        return new $implementation['class']($filepath);
+        $class = 'Drupal\\' . $implementation['class'];
+        return new $class($filepath);
       }
     }
   }
@@ -7723,12 +7733,12 @@ function archiver_get_archiver($file) {
  * @see hook_updater_info()
  * @see hook_updater_info_alter()
  */
-function drupal_get_updaters() {
+function get_updaters() {
   $updaters = &drupal_static(__FUNCTION__);
   if (!isset($updaters)) {
     $updaters = module_invoke_all('updater_info');
-    drupal_alter('updater_info', $updaters);
-    uasort($updaters, 'drupal_sort_weight');
+    alter('updater_info', $updaters);
+    uasort($updaters, 'Drupal\sort_weight');
   }
   return $updaters;
 }
@@ -7743,26 +7753,26 @@ function drupal_get_updaters() {
  * @see hook_filetransfer_info()
  * @see hook_filetransfer_info_alter()
  */
-function drupal_get_filetransfer_info() {
+function get_filetransfer_info() {
   $info = &drupal_static(__FUNCTION__);
   if (!isset($info)) {
     // Since we have to manually set the 'file path' default for each
     // module separately, we can't use module_invoke_all().
     $info = array();
     foreach (module_implements('filetransfer_info') as $module) {
-      $function = $module . '_filetransfer_info';
+      $function = 'Drupal\\' . $module . '_filetransfer_info';
       $result = $function();
       if (isset($result) && is_array($result)) {
         foreach ($result as &$values) {
           if (empty($values['file path'])) {
-            $values['file path'] = drupal_get_path('module', $module);
+            $values['file path'] = get_path('module', $module);
           }
         }
         $info = array_merge_recursive($info, $result);
       }
     }
-    drupal_alter('filetransfer_info', $info);
-    uasort($info, 'drupal_sort_weight');
+    alter('filetransfer_info', $info);
+    uasort($info, 'Drupal\sort_weight');
   }
   return $info;
 }
diff --git a/core/includes/database/database.inc b/core/includes/database/database.inc
index 7c96e07..072233e 100644
--- a/core/includes/database/database.inc
+++ b/core/includes/database/database.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, Iterator, PDO, PDOException, PDOStatement, Traversable, stdClass;
 
 /**
  * @file
@@ -305,7 +307,7 @@ abstract class DatabaseConnection extends PDO {
 
     // Set a specific PDOStatement class if the driver requires that.
     if (!empty($this->statementClass)) {
-      $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this)));
+      $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('Drupal\\' . $this->statementClass, array($this)));
     }
   }
 
@@ -761,10 +763,10 @@ abstract class DatabaseConnection extends PDO {
   public function getDriverClass($class, array $files = array(), $use_autoload = FALSE) {
     if (empty($this->driverClasses[$class])) {
       $driver = $this->driver();
-      $this->driverClasses[$class] = $class . '_' . $driver;
+      $this->driverClasses[$class] = 'Drupal\\' . $class . '_' . $driver;
       Database::loadDriverFile($driver, $files);
       if (!class_exists($this->driverClasses[$class], $use_autoload)) {
-        $this->driverClasses[$class] = $class;
+        $this->driverClasses[$class] = 'Drupal\\' . $class;
       }
     }
     return $this->driverClasses[$class];
@@ -1662,8 +1664,8 @@ abstract class Database {
 
     // We cannot rely on the registry yet, because the registry requires an
     // open database connection.
-    $driver_class = 'DatabaseConnection_' . $driver;
-    require_once DRUPAL_ROOT . '/core/includes/database/' . $driver . '/database.inc';
+    require_once ROOT . '/core/includes/database/' . $driver . '/database.inc';
+    $driver_class = 'Drupal\DatabaseConnection_' . $driver;
     $new_connection = new $driver_class(self::$databaseInfo[$key][$target]);
     $new_connection->setTarget($target);
     $new_connection->setKey($key);
diff --git a/core/includes/database/log.inc b/core/includes/database/log.inc
index ec27ef8..ce6f24e 100644
--- a/core/includes/database/log.inc
+++ b/core/includes/database/log.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/includes/database/mysql/database.inc b/core/includes/database/mysql/database.inc
index e024a7f..f79432d 100644
--- a/core/includes/database/mysql/database.inc
+++ b/core/includes/database/mysql/database.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, PDO, PDOException;
 
 /**
  * @file
diff --git a/core/includes/database/mysql/install.inc b/core/includes/database/mysql/install.inc
index 75f2ae3..23b3071 100644
--- a/core/includes/database/mysql/install.inc
+++ b/core/includes/database/mysql/install.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use PDO;
 
 /**
  * @file
diff --git a/core/includes/database/mysql/query.inc b/core/includes/database/mysql/query.inc
index 888b6a5..4ffc62e 100644
--- a/core/includes/database/mysql/query.inc
+++ b/core/includes/database/mysql/query.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @ingroup database
diff --git a/core/includes/database/mysql/schema.inc b/core/includes/database/mysql/schema.inc
index 4e88fa1..f2e661a 100644
--- a/core/includes/database/mysql/schema.inc
+++ b/core/includes/database/mysql/schema.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, PDO;
 
 /**
  * @file
diff --git a/core/includes/database/pgsql/database.inc b/core/includes/database/pgsql/database.inc
index 68300e5..9e2532b 100644
--- a/core/includes/database/pgsql/database.inc
+++ b/core/includes/database/pgsql/database.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, PDO, PDOException;
 
 /**
  * @file
diff --git a/core/includes/database/pgsql/install.inc b/core/includes/database/pgsql/install.inc
index c350634..d7f7335 100644
--- a/core/includes/database/pgsql/install.inc
+++ b/core/includes/database/pgsql/install.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
diff --git a/core/includes/database/pgsql/query.inc b/core/includes/database/pgsql/query.inc
index f3783a9..52846f2 100644
--- a/core/includes/database/pgsql/query.inc
+++ b/core/includes/database/pgsql/query.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use PDO;
 
 /**
  * @ingroup database
diff --git a/core/includes/database/pgsql/schema.inc b/core/includes/database/pgsql/schema.inc
index 9ed8a26..0f75f54 100644
--- a/core/includes/database/pgsql/schema.inc
+++ b/core/includes/database/pgsql/schema.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
diff --git a/core/includes/database/pgsql/select.inc b/core/includes/database/pgsql/select.inc
index d1d8382..21d2c09 100644
--- a/core/includes/database/pgsql/select.inc
+++ b/core/includes/database/pgsql/select.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/includes/database/prefetch.inc b/core/includes/database/prefetch.inc
index 4f2b19d..0d405e2 100644
--- a/core/includes/database/prefetch.inc
+++ b/core/includes/database/prefetch.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, Iterator, PDO, PDOException, PDOStatement, stdClass;
 
 /**
  * @file
diff --git a/core/includes/database/query.inc b/core/includes/database/query.inc
index 0effeda..a5a869d 100644
--- a/core/includes/database/query.inc
+++ b/core/includes/database/query.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Countable, Exception;
 
 /**
  * @ingroup database
diff --git a/core/includes/database/schema.inc b/core/includes/database/schema.inc
index 27934dc..a91e2a5 100644
--- a/core/includes/database/schema.inc
+++ b/core/includes/database/schema.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -153,7 +155,7 @@ require_once __DIR__ . '/query.inc';
  * );
  * @endcode
  *
- * @see drupal_install_schema()
+ * @see install_schema()
  */
 
 abstract class DatabaseSchema implements QueryPlaceholderInterface {
diff --git a/core/includes/database/select.inc b/core/includes/database/select.inc
index 9bc6b92..2aeb910 100644
--- a/core/includes/database/select.inc
+++ b/core/includes/database/select.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @ingroup database
@@ -1132,11 +1133,12 @@ class SelectQuery extends Query implements SelectQueryInterface {
   /* Implementations of QueryExtendableInterface. */
 
   public function extend($extender_name) {
-    $override_class = $extender_name . '_' . $this->connection->driver();
+    $class = 'Drupal\\' . $extender_name;
+    $override_class = $class . '_' . $this->connection->driver();
     if (class_exists($override_class)) {
-      $extender_name = $override_class;
+      $class = $override_class;
     }
-    return new $extender_name($this, $this->connection);
+    return new $class($this, $this->connection);
   }
 
   public function havingIsNull($field) {
@@ -1230,7 +1232,7 @@ class SelectQuery extends Query implements SelectQueryInterface {
       foreach ($this->alterTags as $tag => $value) {
         $hooks[] = 'query_' . $tag;
       }
-      drupal_alter($hooks, $query);
+      alter($hooks, $query);
     }
 
     $this->prepared = TRUE;
diff --git a/core/includes/database/sqlite/database.inc b/core/includes/database/sqlite/database.inc
index 5de219e..dc7e204 100644
--- a/core/includes/database/sqlite/database.inc
+++ b/core/includes/database/sqlite/database.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, Iterator, PDO, PDOException, PDOStatement;
 
 /**
  * @file
@@ -10,7 +12,7 @@
  * @{
  */
 
-include_once DRUPAL_ROOT . '/core/includes/database/prefetch.inc';
+include_once ROOT . '/core/includes/database/prefetch.inc';
 
 /**
  * Specific SQLite implementation of DatabaseConnection.
diff --git a/core/includes/database/sqlite/install.inc b/core/includes/database/sqlite/install.inc
index 62cbac3..3de9a20 100644
--- a/core/includes/database/sqlite/install.inc
+++ b/core/includes/database/sqlite/install.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -29,7 +30,7 @@ class DatabaseTasks_sqlite extends DatabaseTasks {
 
     // Make the text more accurate for SQLite.
     $form['database']['#title'] = st('Database file');
-    $form['database']['#description'] = st('The absolute path to the file where @drupal data will be stored. This must be writable by the web server and should exist outside of the web root.', array('@drupal' => drupal_install_profile_distribution_name()));
+    $form['database']['#description'] = st('The absolute path to the file where @drupal data will be stored. This must be writable by the web server and should exist outside of the web root.', array('@drupal' => install_profile_distribution_name()));
     $default_database = conf_path(FALSE, TRUE) . '/files/.ht.sqlite';
     $form['database']['#default_value'] = empty($database['database']) ? $default_database : $database['database'];
     return $form;
diff --git a/core/includes/database/sqlite/query.inc b/core/includes/database/sqlite/query.inc
index 6b8a72f..820b08a 100644
--- a/core/includes/database/sqlite/query.inc
+++ b/core/includes/database/sqlite/query.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/includes/database/sqlite/schema.inc b/core/includes/database/sqlite/schema.inc
index c5882f1..58c47d7 100644
--- a/core/includes/database/sqlite/schema.inc
+++ b/core/includes/database/sqlite/schema.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -404,8 +406,8 @@ class DatabaseSchema_sqlite extends DatabaseSchema {
    * @param $table
    *   Name of the table.
    * @return
-   *   An array representing the schema, from drupal_get_schema().
-   * @see drupal_get_schema()
+   *   An array representing the schema, from get_schema().
+   * @see get_schema()
    */
   protected function introspectSchema($table) {
     $mapped_fields = array_flip($this->getFieldTypeMap());
diff --git a/core/includes/database/sqlite/select.inc b/core/includes/database/sqlite/select.inc
index fb926ef..efac722 100644
--- a/core/includes/database/sqlite/select.inc
+++ b/core/includes/database/sqlite/select.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/includes/date.inc b/core/includes/date.inc
index 27634f9..5559f4e 100644
--- a/core/includes/date.inc
+++ b/core/includes/date.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/includes/errors.inc b/core/includes/errors.inc
index eaf2e21..5fa02a6 100644
--- a/core/includes/errors.inc
+++ b/core/includes/errors.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, PDO, PDOException;
 
 /**
  * @file
@@ -27,7 +29,7 @@ const ERROR_REPORTING_DISPLAY_ALL = 2;
  *
  * @ingroup logging_severity_levels
  */
-function drupal_error_levels() {
+function error_levels() {
   $types = array(
     E_ERROR => array('Error', WATCHDOG_ERROR),
     E_WARNING => array('Warning', WATCHDOG_WARNING),
@@ -63,18 +65,18 @@ function drupal_error_levels() {
  * @param $context
  *   An array that points to the active symbol table at the point the error occurred.
  */
-function _drupal_error_handler_real($error_level, $message, $filename, $line, $context) {
+function _error_handler_real($error_level, $message, $filename, $line, $context) {
   if ($error_level & error_reporting()) {
-    $types = drupal_error_levels();
+    $types = error_levels();
     list($severity_msg, $severity_level) = $types[$error_level];
-    $caller = _drupal_get_last_caller(debug_backtrace());
+    $caller = _get_last_caller(debug_backtrace());
 
-    if (!function_exists('filter_xss_admin')) {
-      require_once DRUPAL_ROOT . '/core/includes/common.inc';
+    if (!function_exists('Drupal\filter_xss_admin')) {
+      require_once ROOT . '/core/includes/common.inc';
     }
 
     // We treat recoverable errors as fatal.
-    _drupal_log_error(array(
+    _log_error(array(
       '%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error',
       // The standard PHP error handler considers that the error messages
       // are HTML. We mimick this behavior here.
@@ -93,9 +95,9 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c
  * @param $exception
  *   The exception object that was thrown.
  * @return
- *   An error in the format expected by _drupal_log_error().
+ *   An error in the format expected by _log_error().
  */
-function _drupal_decode_exception($exception) {
+function _decode_exception($exception) {
   $message = $exception->getMessage();
 
   $backtrace = $exception->getTrace();
@@ -108,7 +110,7 @@ function _drupal_decode_exception($exception) {
     // The first element in the stack is the call, the second element gives us the caller.
     // We skip calls that occurred in one of the classes of the database layer
     // or in one of its global functions.
-    $db_functions = array('db_query',  'db_query_range');
+    $db_functions = array('Drupal\db_query',  'Drupal\db_query_range');
     while (!empty($backtrace[1]) && ($caller = $backtrace[1]) &&
         ((isset($caller['class']) && (strpos($caller['class'], 'Query') !== FALSE || strpos($caller['class'], 'Database') !== FALSE || strpos($caller['class'], 'PDO') !== FALSE)) ||
         in_array($caller['function'], $db_functions))) {
@@ -119,7 +121,7 @@ function _drupal_decode_exception($exception) {
       $message .= ": " . $exception->query_string . "; " . print_r($exception->args, TRUE);
     }
   }
-  $caller = _drupal_get_last_caller($backtrace);
+  $caller = _get_last_caller($backtrace);
 
   return array(
     '%type' => get_class($exception),
@@ -141,8 +143,8 @@ function _drupal_decode_exception($exception) {
  * @return
  *   An error message.
  */
-function _drupal_render_exception_safe($exception) {
-  return check_plain(strtr('%type: !message in %function (line %line of %file).', _drupal_decode_exception($exception)));
+function _render_exception_safe($exception) {
+  return check_plain(strtr('%type: !message in %function (line %line of %file).', _decode_exception($exception)));
 }
 
 /**
@@ -178,20 +180,20 @@ function error_displayable($error = NULL) {
  * @param $fatal
  *   TRUE if the error is fatal.
  */
-function _drupal_log_error($error, $fatal = FALSE) {
+function _log_error($error, $fatal = FALSE) {
   // Initialize a maintenance theme if the boostrap was not complete.
-  // Do it early because drupal_set_message() triggers a drupal_theme_initialize().
-  if ($fatal && (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL)) {
+  // Do it early because set_message() triggers a theme_initialize().
+  if ($fatal && (get_bootstrap_phase() != BOOTSTRAP_FULL)) {
     unset($GLOBALS['theme']);
     if (!defined('MAINTENANCE_MODE')) {
       define('MAINTENANCE_MODE', 'error');
     }
-    drupal_maintenance_theme();
+    maintenance_theme();
   }
 
   // When running inside the testing framework, we relay the errors
   // to the tested site by the way of HTTP headers.
-  $test_info = &$GLOBALS['drupal_test_info'];
+  $test_info = &$GLOBALS['test_info'];
   if (!empty($test_info['in_child_site']) && !headers_sent() && (!defined('SIMPLETEST_COLLECT_ERRORS') || SIMPLETEST_COLLECT_ERRORS)) {
     // $number does not use drupal_static as it should not be reset
     // as it uniquely identifies each PHP error.
@@ -212,10 +214,10 @@ function _drupal_log_error($error, $fatal = FALSE) {
   watchdog('php', '%type: !message in %function (line %line of %file).', $error, $error['severity_level']);
 
   if ($fatal) {
-    drupal_add_http_header('Status', '500 Service unavailable (with message)');
+    add_http_header('Status', '500 Service unavailable (with message)');
   }
 
-  if (drupal_is_cli()) {
+  if (is_cli()) {
     if ($fatal) {
       // When called from CLI, simply output a plain text message.
       print html_entity_decode(strip_tags(t('%type: !message in %function (line %line of %file).', $error))). "\n";
@@ -243,11 +245,11 @@ function _drupal_log_error($error, $fatal = FALSE) {
         $class = 'status';
       }
 
-      drupal_set_message(t('%type: !message in %function (line %line of %file).', $error), $class);
+      set_message(t('%type: !message in %function (line %line of %file).', $error), $class);
     }
 
     if ($fatal) {
-      drupal_set_title(t('Error'));
+      set_title(t('Error'));
       // We fallback to a maintenance page at this point, because the page generation
       // itself can generate errors.
       print theme('maintenance_page', array('content' => t('The website encountered an unexpected error. Please try again later.')));
@@ -264,10 +266,10 @@ function _drupal_log_error($error, $fatal = FALSE) {
  * @return
  *   An associative array with keys 'file', 'line' and 'function'.
  */
-function _drupal_get_last_caller($backtrace) {
+function _get_last_caller($backtrace) {
   // Errors that occur inside PHP internal functions do not generate
   // information about file and line. Ignore black listed functions.
-  $blacklist = array('debug', '_drupal_error_handler', '_drupal_exception_handler');
+  $blacklist = array('Drupal\debug', 'Drupal\_error_handler', 'Drupal\_exception_handler');
   while (($backtrace && !isset($backtrace[0]['line'])) ||
          (isset($backtrace[1]['function']) && in_array($backtrace[1]['function'], $blacklist))) {
     array_shift($backtrace);
diff --git a/core/includes/file.inc b/core/includes/file.inc
index 05bf6c1..dfa1cf0 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -12,7 +14,7 @@
  * File API is needed before a bootstrap, or in an alternate order (e.g.
  * maintenance theme).
  */
-require_once DRUPAL_ROOT . '/core/includes/stream_wrappers.inc';
+require_once ROOT . '/core/includes/stream_wrappers.inc';
 
 /**
  * @defgroup file File interface
@@ -31,7 +33,7 @@ require_once DRUPAL_ROOT . '/core/includes/stream_wrappers.inc';
  * - status: A bitmapped field indicating the status of the file. The first 8
  *   bits are reserved for Drupal core. The least significant bit indicates
  *   temporary (0) or permanent (1). Temporary files older than
- *   DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during cron runs.
+ *   MAXIMUM_TEMP_FILE_AGE will be removed during cron runs.
  * - timestamp: UNIX timestamp for the date the file was added to the database.
  */
 
@@ -63,7 +65,7 @@ const FILE_EXISTS_ERROR = 2;
 /**
  * Indicates that the file is permanent and should not be deleted.
  *
- * Temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed
+ * Temporary files older than MAXIMUM_TEMP_FILE_AGE will be removed
  * during cron runs, but permanent files will not be removed during the file
  * garbage collection process.
  */
@@ -133,11 +135,12 @@ function file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL) {
       // Add defaults.
       $wrappers[$scheme] += array('type' => STREAM_WRAPPERS_NORMAL);
     }
-    drupal_alter('stream_wrappers', $wrappers);
+    alter('stream_wrappers', $wrappers);
     $existing = stream_get_wrappers();
     foreach ($wrappers as $scheme => $info) {
+      $class = 'Drupal\\' . $info['class'];
       // We only register classes that implement our interface.
-      if (in_array('DrupalStreamWrapperInterface', class_implements($info['class']), TRUE)) {
+      if (in_array('Drupal\DrupalStreamWrapperInterface', class_implements($class), TRUE)) {
         // Record whether we are overriding an existing scheme.
         if (in_array($scheme, $existing, TRUE)) {
           $wrappers[$scheme]['override'] = TRUE;
@@ -147,10 +150,10 @@ function file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL) {
           $wrappers[$scheme]['override'] = FALSE;
         }
         if (($info['type'] & STREAM_WRAPPERS_LOCAL) == STREAM_WRAPPERS_LOCAL) {
-          stream_wrapper_register($scheme, $info['class']);
+          stream_wrapper_register($scheme, $class);
         }
         else {
-          stream_wrapper_register($scheme, $info['class'], STREAM_IS_URL);
+          stream_wrapper_register($scheme, $class, STREAM_IS_URL);
         }
       }
       // Pre-populate the static cache with the filters most typically used.
@@ -175,7 +178,7 @@ function file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL) {
 }
 
 /**
- * Returns the stream wrapper class name for a given scheme.
+ * Returns the fully qualified stream wrapper class name for a given scheme.
  *
  * @param $scheme
  *   Stream scheme.
@@ -185,7 +188,7 @@ function file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL) {
  */
 function file_stream_wrapper_get_class($scheme) {
   $wrappers = file_get_stream_wrappers();
-  return empty($wrappers[$scheme]) ? FALSE : $wrappers[$scheme]['class'];
+  return empty($wrappers[$scheme]) ? FALSE : 'Drupal\\' . $wrappers[$scheme]['class'];
 }
 
 /**
@@ -306,7 +309,7 @@ function file_stream_wrapper_uri_normalize($uri) {
  *   Returns a new stream wrapper object appropriate for the given URI or FALSE
  *   if no registered handler could be found. For example, a URI of
  *   "private://example.txt" would return a new private stream wrapper object
- *   (DrupalPrivateStreamWrapper).
+ *   (PrivateStreamWrapper).
  */
 function file_stream_wrapper_get_instance_by_uri($uri) {
   $scheme = file_uri_scheme($uri);
@@ -338,7 +341,7 @@ function file_stream_wrapper_get_instance_by_uri($uri) {
  * @return
  *   Returns a new stream wrapper object appropriate for the given $scheme.
  *   For example, for the public scheme a stream wrapper object
- *   (DrupalPublicStreamWrapper).
+ *   (PublicStreamWrapper).
  *   FALSE is returned if no registered handler could be found.
  */
 function file_stream_wrapper_get_instance_by_scheme($scheme) {
@@ -379,7 +382,7 @@ function file_stream_wrapper_get_instance_by_scheme($scheme) {
 function file_create_url($uri) {
   // Allow the URI to be altered, e.g. to serve a file from a CDN or static
   // file server.
-  drupal_alter('file_url', $uri);
+  alter('file_url', $uri);
 
   $scheme = file_uri_scheme($uri);
 
@@ -397,7 +400,7 @@ function file_create_url($uri) {
     else {
       // If this is not a properly formatted stream, then it is a shipped file.
       // Therefore, return the urlencoded URI with the base URL prepended.
-      return $GLOBALS['base_url'] . '/' . drupal_encode_path($uri);
+      return $GLOBALS['base_url'] . '/' . encode_path($uri);
     }
   }
   elseif ($scheme == 'http' || $scheme == 'https') {
@@ -581,13 +584,13 @@ function file_save(stdClass $file) {
   module_invoke_all('entity_presave', $file, 'file');
 
   if (empty($file->fid)) {
-    drupal_write_record('file_managed', $file);
+    write_record('file_managed', $file);
     // Inform modules about the newly added file.
     module_invoke_all('file_insert', $file);
     module_invoke_all('entity_insert', $file, 'file');
   }
   else {
-    drupal_write_record('file_managed', $file, 'fid');
+    write_record('file_managed', $file, 'fid');
     // Inform modules that the file has been updated.
     module_invoke_all('file_update', $file);
     module_invoke_all('entity_update', $file, 'file');
@@ -762,7 +765,7 @@ function file_copy(stdClass $source, $destination = NULL, $replace = FILE_EXISTS
     else {
       watchdog('file', 'File %file could not be copied because the destination %destination is invalid. This is often caused by improper use of file_copy() or a missing stream wrapper.', array('%file' => $source->uri, '%destination' => $destination));
     }
-    drupal_set_message(t('The specified file %file could not be copied because the destination is invalid. More information is available in the system log.', array('%file' => $source->uri)), 'error');
+    set_message(t('The specified file %file could not be copied because the destination is invalid. More information is available in the system log.', array('%file' => $source->uri)), 'error');
     return FALSE;
   }
 
@@ -770,7 +773,7 @@ function file_copy(stdClass $source, $destination = NULL, $replace = FILE_EXISTS
     $file = clone $source;
     $file->fid = NULL;
     $file->uri = $uri;
-    $file->filename = drupal_basename($uri);
+    $file->filename = basename($uri);
     // If we are replacing an existing file re-use its database record.
     if ($replace == FILE_EXISTS_REPLACE) {
       $existing_files = file_load_multiple(array(), array('uri' => $uri));
@@ -783,7 +786,7 @@ function file_copy(stdClass $source, $destination = NULL, $replace = FILE_EXISTS
     // If we are renaming around an existing file (rather than a directory),
     // use its basename for the filename.
     elseif ($replace == FILE_EXISTS_RENAME && is_file($destination)) {
-      $file->filename = drupal_basename($destination);
+      $file->filename = basename($destination);
     }
 
     $file = file_save($file);
@@ -858,8 +861,8 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
 
   // Assert that the source file actually exists.
   if (!file_exists($source)) {
-    // @todo Replace drupal_set_message() calls with exceptions instead.
-    drupal_set_message(t('The specified file %file could not be copied because no file by that name exists. Please check that you supplied the correct filename.', array('%file' => $original_source)), 'error');
+    // @todo Replace set_message() calls with exceptions instead.
+    set_message(t('The specified file %file could not be copied because no file by that name exists. Please check that you supplied the correct filename.', array('%file' => $original_source)), 'error');
     if (($realpath = drupal_realpath($original_source)) !== FALSE) {
       watchdog('file', 'File %file (%realpath) could not be copied because it does not exist.', array('%file' => $original_source, '%realpath' => $realpath));
     }
@@ -871,14 +874,14 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
 
   // Build a destination URI if necessary.
   if (!isset($destination)) {
-    $destination = file_build_uri(drupal_basename($source));
+    $destination = file_build_uri(basename($source));
   }
 
 
   // Prepare the destination directory.
   if (file_prepare_directory($destination)) {
     // The destination is already a directory, so append the source basename.
-    $destination = file_stream_wrapper_uri_normalize($destination . '/' . drupal_basename($source));
+    $destination = file_stream_wrapper_uri_normalize($destination . '/' . basename($source));
   }
   else {
     // Perhaps $destination is a dir/file?
@@ -886,7 +889,7 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
     if (!file_prepare_directory($dirname)) {
       // The destination is not valid.
       watchdog('file', 'File %file could not be copied because the destination directory %destination is not configured correctly.', array('%file' => $original_source, '%destination' => $dirname));
-      drupal_set_message(t('The specified file %file could not be copied because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.', array('%file' => $original_source)), 'error');
+      set_message(t('The specified file %file could not be copied because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.', array('%file' => $original_source)), 'error');
       return FALSE;
     }
   }
@@ -894,7 +897,7 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
   // Determine whether we can perform this operation based on overwrite rules.
   $destination = file_destination($destination, $replace);
   if ($destination === FALSE) {
-    drupal_set_message(t('The file %file could not be copied because a file by that name already exists in the destination directory.', array('%file' => $original_source)), 'error');
+    set_message(t('The file %file could not be copied because a file by that name already exists in the destination directory.', array('%file' => $original_source)), 'error');
     watchdog('file', 'File %file could not be copied because a file by that name already exists in the destination directory (%directory)', array('%file' => $original_source, '%destination' => $destination));
     return FALSE;
   }
@@ -903,7 +906,7 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
   $real_source = drupal_realpath($source);
   $real_destination = drupal_realpath($destination);
   if ($source == $destination || ($real_source !== FALSE) && ($real_source == $real_destination)) {
-    drupal_set_message(t('The specified file %file was not copied because it would overwrite itself.', array('%file' => $source)), 'error');
+    set_message(t('The specified file %file was not copied because it would overwrite itself.', array('%file' => $source)), 'error');
     watchdog('file', 'File %file could not be copied because it would overwrite itself.', array('%file' => $source));
     return FALSE;
   }
@@ -958,7 +961,7 @@ function file_destination($destination, $replace) {
         break;
 
       case FILE_EXISTS_RENAME:
-        $basename = drupal_basename($destination);
+        $basename = basename($destination);
         $directory = drupal_dirname($destination);
         $destination = file_create_filename($basename, $directory);
         break;
@@ -1012,7 +1015,7 @@ function file_move(stdClass $source, $destination = NULL, $replace = FILE_EXISTS
     else {
       watchdog('file', 'File %file could not be moved because the destination %destination is invalid. This may be caused by improper use of file_move() or a missing stream wrapper.', array('%file' => $source->uri, '%destination' => $destination));
     }
-    drupal_set_message(t('The specified file %file could not be moved because the destination is invalid. More information is available in the system log.', array('%file' => $source->uri)), 'error');
+    set_message(t('The specified file %file could not be moved because the destination is invalid. More information is available in the system log.', array('%file' => $source->uri)), 'error');
     return FALSE;
   }
 
@@ -1033,7 +1036,7 @@ function file_move(stdClass $source, $destination = NULL, $replace = FILE_EXISTS
     // If we are renaming around an existing file (rather than a directory),
     // use its basename for the filename.
     elseif ($replace == FILE_EXISTS_RENAME && is_file($destination)) {
-      $file->filename = drupal_basename($destination);
+      $file->filename = basename($destination);
     }
 
     $file = file_save($file);
@@ -1107,7 +1110,7 @@ function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXIST
  * @param $extensions
  *   A space-separated list of extensions that should not be altered.
  * @param $alerts
- *   If TRUE, drupal_set_message() will be called to display a message if the
+ *   If TRUE, set_message() will be called to display a message if the
  *   file name was changed.
  *
  * @return
@@ -1138,7 +1141,7 @@ function file_munge_filename($filename, $extensions, $alerts = TRUE) {
     $filename = $new_filename . '.' . $final_extension;
 
     if ($alerts && $original != $filename) {
-      drupal_set_message(t('For security reasons, your upload has been renamed to %filename.', array('%filename' => $filename)));
+      set_message(t('For security reasons, your upload has been renamed to %filename.', array('%filename' => $filename)));
     }
   }
 
@@ -1244,7 +1247,7 @@ function file_delete(stdClass $file, $force = FALSE) {
     else {
       watchdog('file', 'File %file could not be deleted because it is not a valid URI. This may be caused by improper use of file_delete() or a missing stream wrapper.', array('%file' => $file->uri));
     }
-    drupal_set_message(t('The specified file %file could not be deleted because it is not a valid URI. More information is available in the system log.', array('%file' => $file->uri)), 'error');
+    set_message(t('The specified file %file could not be deleted because it is not a valid URI. More information is available in the system log.', array('%file' => $file->uri)), 'error');
     return FALSE;
   }
 
@@ -1432,12 +1435,12 @@ function file_save_upload($source, $validators = array(), $destination = FALSE,
   switch ($_FILES['files']['error'][$source]) {
     case UPLOAD_ERR_INI_SIZE:
     case UPLOAD_ERR_FORM_SIZE:
-      drupal_set_message(t('The file %file could not be saved because it exceeds %maxsize, the maximum allowed size for uploads.', array('%file' => $_FILES['files']['name'][$source], '%maxsize' => format_size(file_upload_max_size()))), 'error');
+      set_message(t('The file %file could not be saved because it exceeds %maxsize, the maximum allowed size for uploads.', array('%file' => $_FILES['files']['name'][$source], '%maxsize' => format_size(file_upload_max_size()))), 'error');
       return FALSE;
 
     case UPLOAD_ERR_PARTIAL:
     case UPLOAD_ERR_NO_FILE:
-      drupal_set_message(t('The file %file could not be saved because the upload did not complete.', array('%file' => $_FILES['files']['name'][$source])), 'error');
+      set_message(t('The file %file could not be saved because the upload did not complete.', array('%file' => $_FILES['files']['name'][$source])), 'error');
       return FALSE;
 
     case UPLOAD_ERR_OK:
@@ -1449,7 +1452,7 @@ function file_save_upload($source, $validators = array(), $destination = FALSE,
 
     // Unknown error
     default:
-      drupal_set_message(t('The file %file could not be saved. An unknown error has occurred.', array('%file' => $_FILES['files']['name'][$source])), 'error');
+      set_message(t('The file %file could not be saved. An unknown error has occurred.', array('%file' => $_FILES['files']['name'][$source])), 'error');
       return FALSE;
   }
 
@@ -1457,7 +1460,7 @@ function file_save_upload($source, $validators = array(), $destination = FALSE,
   $file = new stdClass();
   $file->uid      = $user->uid;
   $file->status   = 0;
-  $file->filename = trim(drupal_basename($_FILES['files']['name'][$source]), '.');
+  $file->filename = trim(basename($_FILES['files']['name'][$source]), '.');
   $file->uri      = $_FILES['files']['tmp_name'][$source];
   $file->filemime = file_get_mimetype($file->filename);
   $file->filesize = $_FILES['files']['size'][$source];
@@ -1501,7 +1504,7 @@ function file_save_upload($source, $validators = array(), $destination = FALSE,
     // to add it here or else the file upload will fail.
     if (!empty($extensions)) {
       $validators['file_validate_extensions'][0] .= ' txt';
-      drupal_set_message(t('For security reasons, your upload has been renamed to %filename.', array('%filename' => $file->filename)));
+      set_message(t('For security reasons, your upload has been renamed to %filename.', array('%filename' => $file->filename)));
     }
   }
 
@@ -1513,7 +1516,7 @@ function file_save_upload($source, $validators = array(), $destination = FALSE,
   // Assert that the destination contains a valid stream.
   $destination_scheme = file_uri_scheme($destination);
   if (!$destination_scheme || !file_stream_wrapper_valid_scheme($destination_scheme)) {
-    drupal_set_message(t('The file could not be uploaded because the destination %destination is invalid.', array('%destination' => $destination)), 'error');
+    set_message(t('The file could not be uploaded because the destination %destination is invalid.', array('%destination' => $destination)), 'error');
     return FALSE;
   }
 
@@ -1526,7 +1529,7 @@ function file_save_upload($source, $validators = array(), $destination = FALSE,
   // If file_destination() returns FALSE then $replace == FILE_EXISTS_ERROR and
   // there's an existing file so we need to bail.
   if ($file->destination === FALSE) {
-    drupal_set_message(t('The file %source could not be uploaded because a file by that name already exists in the destination %directory.', array('%source' => $source, '%directory' => $destination)), 'error');
+    set_message(t('The file %source could not be uploaded because a file by that name already exists in the destination %directory.', array('%source' => $source, '%directory' => $destination)), 'error');
     return FALSE;
   }
 
@@ -1642,6 +1645,7 @@ function file_validate(stdClass &$file, $validators = array()) {
   // Call the validation functions specified by this function's caller.
   $errors = array();
   foreach ($validators as $function => $args) {
+    $function = 'Drupal\\' . $function;
     if (function_exists($function)) {
       array_unshift($args, $file);
       $errors = array_merge($errors, call_user_func_array($function, $args));
@@ -1795,7 +1799,7 @@ function file_validate_image_resolution(stdClass $file, $maximum_dimensions = 0,
           image_scale($image, $width, $height);
           image_save($image);
           $file->filesize = $image->info['file_size'];
-          drupal_set_message(t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', array('%dimensions' => $maximum_dimensions)));
+          set_message(t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', array('%dimensions' => $maximum_dimensions)));
         }
         else {
           $errors[] = t('The image is too large; the maximum dimensions are %dimensions pixels.', array('%dimensions' => $maximum_dimensions));
@@ -1846,7 +1850,7 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM
   }
   if (!file_valid_uri($destination)) {
     watchdog('file', 'The data could not be saved because the destination %destination is invalid. This may be caused by improper use of file_save_data() or a missing stream wrapper.', array('%destination' => $destination));
-    drupal_set_message(t('The data could not be saved because the destination is invalid. More information is available in the system log.'), 'error');
+    set_message(t('The data could not be saved because the destination is invalid. More information is available in the system log.'), 'error');
     return FALSE;
   }
 
@@ -1855,7 +1859,7 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM
     $file = new stdClass();
     $file->fid = NULL;
     $file->uri = $uri;
-    $file->filename = drupal_basename($uri);
+    $file->filename = basename($uri);
     $file->filemime = file_get_mimetype($file->uri);
     $file->uid      = $user->uid;
     $file->status   = FILE_STATUS_PERMANENT;
@@ -1871,7 +1875,7 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM
     // If we are renaming around an existing file (rather than a directory),
     // use its basename for the filename.
     elseif ($replace == FILE_EXISTS_RENAME && is_file($destination)) {
-      $file->filename = drupal_basename($destination);
+      $file->filename = basename($destination);
     }
 
     return file_save($file);
@@ -1908,7 +1912,7 @@ function file_unmanaged_save_data($data, $destination = NULL, $replace = FILE_EX
   // Write the data to a temporary file.
   $temp_name = drupal_tempnam('temporary://', 'file');
   if (file_put_contents($temp_name, $data) === FALSE) {
-    drupal_set_message(t('The file could not be created.'), 'error');
+    set_message(t('The file could not be created.'), 'error');
     return FALSE;
   }
 
@@ -1932,9 +1936,9 @@ function file_transfer($uri, $headers) {
   }
 
   foreach ($headers as $name => $value) {
-    drupal_add_http_header($name, $value);
+    add_http_header($name, $value);
   }
-  drupal_send_headers();
+  send_headers();
   $scheme = file_uri_scheme($uri);
   // Transfer file in 1024 byte chunks to save memory usage.
   if ($scheme && file_stream_wrapper_valid_scheme($scheme) && $fd = fopen($uri, 'rb')) {
@@ -1944,7 +1948,7 @@ function file_transfer($uri, $headers) {
     fclose($fd);
   }
   else {
-    drupal_not_found();
+    not_found();
   }
   drupal_exit();
 }
@@ -1955,9 +1959,9 @@ function file_transfer($uri, $headers) {
  * Call modules that implement hook_file_download() to find out if a file is
  * accessible and what headers it should be transferred with. If one or more
  * modules returned headers the download will start with the returned headers.
- * If a module returns -1 drupal_access_denied() will be returned. If the file
- * exists but no modules responded drupal_access_denied() will be returned.
- * If the file does not exist drupal_not_found() will be returned.
+ * If a module returns -1 access_denied() will be returned. If the file
+ * exists but no modules responded access_denied() will be returned.
+ * If the file does not exist not_found() will be returned.
  *
  * @see hook_file_download()
  */
@@ -1974,10 +1978,10 @@ function file_download() {
     // headers instead, use array_merge() to merge the returned arrays.
     $headers = array();
     foreach (module_implements('file_download') as $module) {
-      $function = $module . '_file_download';
+      $function = 'Drupal\\' . $module . '_file_download';
       $result = $function($uri);
       if ($result == -1) {
-        return drupal_access_denied();
+        return access_denied();
       }
       if (isset($result) && is_array($result)) {
         $headers = array_merge($headers, $result);
@@ -1986,9 +1990,9 @@ function file_download() {
     if (count($headers)) {
       file_transfer($uri, $headers);
     }
-    return drupal_access_denied();
+    return access_denied();
   }
-  return drupal_not_found();
+  return not_found();
 }
 
 
@@ -2056,7 +2060,8 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
           $key = $options['key'];
           $files[$file->$key] = $file;
           if ($options['callback']) {
-            $options['callback']($uri);
+            $function = 'Drupal\\' . $options['callback'];
+            $function($uri);
           }
         }
       }
@@ -2117,7 +2122,7 @@ function file_get_mimetype($uri, $mapping = NULL) {
   else {
     // getMimeType() is not implementation specific, so we can directly
     // call it without an instance.
-    return DrupalLocalStreamWrapper::getMimeType($uri, $mapping);
+    return LocalStreamWrapper::getMimeType($uri, $mapping);
   }
 }
 
@@ -2228,7 +2233,7 @@ function drupal_unlink($uri, $context = NULL) {
  *   The absolute local filesystem path (with no symbolic links), or FALSE on
  *   failure.
  *
- * @see DrupalStreamWrapperInterface::realpath()
+ * @see StreamWrapperInterface::realpath()
  * @see http://php.net/manual/function.realpath.php
  * @ingroup php_wrappers
  * @todo: This function is deprecated, and should be removed wherever possible.
@@ -2285,7 +2290,7 @@ function drupal_dirname($uri) {
  *
  * @ingroup php_wrappers
  */
-function drupal_basename($uri, $suffix = NULL) {
+function basename($uri, $suffix = NULL) {
   $separators = '/';
   if (DIRECTORY_SEPARATOR != '/') {
     // For Windows OS add special separator.
@@ -2399,7 +2404,7 @@ function drupal_tempnam($directory, $prefix) {
     $wrapper = file_stream_wrapper_get_instance_by_scheme($scheme);
 
     if ($filename = tempnam($wrapper->getDirectoryPath(), $prefix)) {
-      return $scheme . '://' . drupal_basename($filename);
+      return $scheme . '://' . basename($filename);
     }
     else {
       return FALSE;
diff --git a/core/includes/file.mimetypes.inc b/core/includes/file.mimetypes.inc
index 7468a60..f47b57e 100644
--- a/core/includes/file.mimetypes.inc
+++ b/core/includes/file.mimetypes.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -20,7 +21,7 @@ function file_mimetype_mapping() {
   if (!isset($mapping)) {
     $mapping = file_default_mimetype_mapping();
     // Allow modules to alter the default mapping.
-    drupal_alter('file_mimetype_mapping', $mapping);
+    alter('file_mimetype_mapping', $mapping);
   }
   return $mapping;
 }
diff --git a/core/includes/filetransfer/filetransfer.inc b/core/includes/filetransfer/filetransfer.inc
index af7dbdd..23d87d6 100644
--- a/core/includes/filetransfer/filetransfer.inc
+++ b/core/includes/filetransfer/filetransfer.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, Iterator, RecursiveDirectoryIterator, RecursiveIteratorIterator;
 
 /**
  * @file
@@ -212,7 +214,7 @@ abstract class FileTransfer {
    */
   protected function copyDirectoryJailed($source, $destination) {
     if ($this->isDirectory($destination)) {
-      $destination = $destination . '/' . drupal_basename($source);
+      $destination = $destination . '/' . basename($source);
     }
     $this->createDirectory($destination);
     foreach (new RecursiveIteratorIterator(new SkipDotsRecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST) as $filename => $file) {
@@ -303,7 +305,7 @@ abstract class FileTransfer {
     $chroot = '';
     while (count($parts)) {
       $check = implode($parts, '/');
-      if ($this->isFile($check . '/' . drupal_basename(__FILE__))) {
+      if ($this->isFile($check . '/' . basename(__FILE__))) {
         // Remove the trailing slash.
         return substr($chroot, 0, -1);
       }
diff --git a/core/includes/filetransfer/ftp.inc b/core/includes/filetransfer/ftp.inc
index 838dc7c..e83df51 100644
--- a/core/includes/filetransfer/ftp.inc
+++ b/core/includes/filetransfer/ftp.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * Base class for FTP implementations.
@@ -28,14 +30,11 @@ abstract class FileTransferFTP extends FileTransfer {
     $hostname = empty($settings['advanced']['hostname']) ? 'localhost' : $settings['advanced']['hostname'];
     $port = empty($settings['advanced']['port']) ? 21 : $settings['advanced']['port'];
 
-    if (function_exists('ftp_connect')) {
-      $class = 'FileTransferFTPExtension';
-    }
-    else {
+    if (!function_exists('ftp_connect')) {
       throw new FileTransferException('No FTP backend available.');
     }
 
-    return new $class($jail, $username, $password, $hostname, $port);
+    return new FileTransferFTPExtension($jail, $username, $password, $hostname, $port);
   }
 
   /**
diff --git a/core/includes/filetransfer/local.inc b/core/includes/filetransfer/local.inc
index b125989..baf4e84 100644
--- a/core/includes/filetransfer/local.inc
+++ b/core/includes/filetransfer/local.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, Iterator, RecursiveDirectoryIterator, RecursiveIteratorIterator;
 
 /**
  * The local connection class for copying files as the httpd user.
diff --git a/core/includes/filetransfer/ssh.inc b/core/includes/filetransfer/ssh.inc
index 43ec324..b7231f8 100644
--- a/core/includes/filetransfer/ssh.inc
+++ b/core/includes/filetransfer/ssh.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * The SSH connection class for the update module.
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 5663ac6..f1fdc73 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @defgroup forms Form builder functions
@@ -28,18 +29,18 @@
  * presentation, while simplifying code and reducing the amount of HTML that
  * must be explicitly generated by modules.
  *
- * The primary function used with forms is drupal_get_form(), which is
+ * The primary function used with forms is get_form(), which is
  * used for forms presented interactively to a user. Forms can also be built and
  * submitted programmatically without any user input using the
- * drupal_form_submit() function.
+ * form_submit() function.
  *
- * drupal_get_form() handles retrieving, processing, and displaying a rendered
+ * get_form() handles retrieving, processing, and displaying a rendered
  * HTML form for modules automatically.
  *
- * Here is an example of how to use drupal_get_form() and a form builder
+ * Here is an example of how to use get_form() and a form builder
  * function:
  * @code
- * $form = drupal_get_form('my_module_example_form');
+ * $form = get_form('my_module_example_form');
  * ...
  * function my_module_example_form($form, &$form_state) {
  *   $form['submit'] = array(
@@ -59,7 +60,7 @@
  * Or with any number of additional arguments:
  * @code
  * $extra = "extra";
- * $form = drupal_get_form('my_module_example_form', $extra);
+ * $form = get_form('my_module_example_form', $extra);
  * ...
  * function my_module_example_form($form, &$form_state, $extra) {
  *   $form['submit'] = array(
@@ -86,11 +87,11 @@
  * passed by reference to most functions, so they use it to communicate with
  * the form system and each other.
  *
- * See drupal_build_form() for documentation of $form_state keys.
+ * See build_form() for documentation of $form_state keys.
  */
 
 /**
- * Wrapper for drupal_build_form() for use when $form_state is not needed.
+ * Wrapper for build_form() for use when $form_state is not needed.
  *
  * @param $form_id
  *   The unique string identifying the desired form. If a function with that
@@ -101,7 +102,7 @@
  *   search_forms(), and user_forms().
  * @param ...
  *   Any additional arguments are passed on to the functions called by
- *   drupal_get_form(), including the unique form constructor function. For
+ *   get_form(), including the unique form constructor function. For
  *   example, the node_edit form requires that a node object is passed in here
  *   when it is called. These are available to implementations of
  *   hook_form_alter() and hook_form_FORM_ID_alter() as the array
@@ -110,9 +111,9 @@
  * @return
  *   The form array.
  *
- * @see drupal_build_form()
+ * @see build_form()
  */
-function drupal_get_form($form_id) {
+function get_form($form_id) {
   $form_state = array();
 
   $args = func_get_args();
@@ -120,7 +121,7 @@ function drupal_get_form($form_id) {
   array_shift($args);
   $form_state['build_info']['args'] = $args;
 
-  return drupal_build_form($form_id, $form_state);
+  return build_form($form_id, $form_state);
 }
 
 /**
@@ -159,10 +160,10 @@ function drupal_get_form($form_id) {
  *     - base_form_id: Identification for a base form, as declared in a
  *       hook_forms() implementation.
  *   - rebuild_info: Internal. Similar to 'build_info', but pertaining to
- *     drupal_rebuild_form().
+ *     rebuild_form().
  *   - rebuild: Normally, after the entire form processing is completed and
  *     submit handlers have run, a form is considered to be done and
- *     drupal_redirect_form() will redirect the user to a new page using a GET
+ *     redirect_form() will redirect the user to a new page using a GET
  *     request (so a browser refresh does not re-submit the form). However, if
  *     'rebuild' has been set to TRUE, then a new copy of the form is
  *     immediately built and sent to the browser, instead of a redirect. This is
@@ -175,9 +176,9 @@ function drupal_get_form($form_id) {
  *     errors.
  *   - redirect: Used to redirect the form on submission. It may either be a
  *     string containing the destination URL, or an array of arguments
- *     compatible with drupal_goto(). See drupal_redirect_form() for complete
+ *     compatible with redirect(). See redirect_form() for complete
  *     information.
- *   - no_redirect: If set to TRUE the form will NOT perform a drupal_goto(),
+ *   - no_redirect: If set to TRUE the form will NOT perform a redirect(),
  *     even if 'redirect' is set.
  *   - method: The HTTP form method to use for finding the input for this form.
  *     May be 'post' or 'get'. Defaults to 'post'. Note that 'get' method
@@ -226,9 +227,9 @@ function drupal_get_form($form_id) {
  *     again. Setting this to TRUE will force that to happen. This is most
  *     likely to occur during Ajax operations.
  *   - programmed: If TRUE, the form was submitted programmatically, usually
- *     invoked via drupal_form_submit(). Defaults to FALSE.
+ *     invoked via form_submit(). Defaults to FALSE.
  *   - process_input: Boolean flag. TRUE signifies correct form submission.
- *     This is always TRUE for programmed forms coming from drupal_form_submit()
+ *     This is always TRUE for programmed forms coming from form_submit()
  *     (see 'programmed' key), or if the form_id coming from the $_POST data is
  *     set and matches the current form_id.
  *   - submitted: If TRUE, the form has been submitted. Defaults to FALSE.
@@ -278,19 +279,19 @@ function drupal_get_form($form_id) {
  *     wizards, may define a form builder function name that returns a form
  *     structure, which is passed on to the actual form builder function.
  *     Such implementations may either define the 'wrapper_callback' via
- *     hook_forms() or have to invoke drupal_build_form() (instead of
- *     drupal_get_form()) on their own in a custom menu callback to prepare
+ *     hook_forms() or have to invoke build_form() (instead of
+ *     get_form()) on their own in a custom menu callback to prepare
  *     $form_state accordingly.
  *   Information on how certain $form_state properties control redirection
- *   behavior after form submission may be found in drupal_redirect_form().
+ *   behavior after form submission may be found in redirect_form().
  *
  * @return
  *   The rendered form. This function may also perform a redirect and hence may
  *   not return at all, depending upon the $form_state flags that were set.
  *
- * @see drupal_redirect_form()
+ * @see redirect_form()
  */
-function drupal_build_form($form_id, &$form_state) {
+function build_form($form_id, &$form_state) {
   // Ensure some defaults; if already set they will not be overridden.
   $form_state += form_state_defaults();
 
@@ -303,7 +304,7 @@ function drupal_build_form($form_id, &$form_state) {
     // already been processed, but needs to be rebuilt. See _batch_finished().
     $form_state = $_SESSION['batch_form_state'];
     unset($_SESSION['batch_form_state']);
-    return drupal_rebuild_form($form_id, $form_state);
+    return rebuild_form($form_id, $form_state);
   }
 
   // If the incoming input contains a form_build_id, we'll check the cache for a
@@ -327,14 +328,14 @@ function drupal_build_form($form_id, &$form_state) {
       $form_state_before_retrieval = $form_state;
     }
 
-    $form = drupal_retrieve_form($form_id, $form_state);
-    drupal_prepare_form($form_id, $form, $form_state);
+    $form = retrieve_form($form_id, $form_state);
+    prepare_form($form_id, $form, $form_state);
 
     // form_set_cache() removes uncacheable $form_state keys defined in
     // form_state_keys_no_cache() in order for multi-step forms to work
     // properly. This means that form processing logic for single-step forms
     // using $form_state['cache'] may depend on data stored in those keys
-    // during drupal_retrieve_form()/drupal_prepare_form(), but form
+    // during retrieve_form()/prepare_form(), but form
     // processing should not depend on whether the form is cached or not, so
     // $form_state is adjusted to match what it would be after a
     // form_set_cache()/form_get_cache() sequence. These exceptions are
@@ -362,10 +363,10 @@ function drupal_build_form($form_id, &$form_state) {
   //   appropriate information persists to the next page request.
   // All of the handlers in the pipeline receive $form_state by reference and
   // can use it to know or update information about the state of the form.
-  drupal_process_form($form_id, $form, $form_state);
+  process_form($form_id, $form, $form_state);
 
   // If this was a successful submission of a single-step form or the last step
-  // of a multi-step form, then drupal_process_form() issued a redirect to
+  // of a multi-step form, then process_form() issued a redirect to
   // another page, or back to this page, but as a new request. Therefore, if
   // we're here, it means that this is either a form being viewed initially
   // before any user input, or there was a validation error requiring the form
@@ -404,7 +405,7 @@ function form_state_defaults() {
  * Constructs a new $form from the information in $form_state.
  *
  * This is the key function for making multi-step forms advance from step to
- * step. It is called by drupal_process_form() when all user input processing,
+ * step. It is called by process_form() when all user input processing,
  * including calling validation and submission handlers, for the request is
  * finished. If a validate or submit handler set $form_state['rebuild'] to TRUE,
  * and if other conditions don't preempt a rebuild from happening, then this
@@ -436,11 +437,11 @@ function form_state_defaults() {
  * @return
  *   The newly built form.
  *
- * @see drupal_process_form()
+ * @see process_form()
  * @see ajax_form_callback()
  */
-function drupal_rebuild_form($form_id, &$form_state, $old_form = NULL) {
-  $form = drupal_retrieve_form($form_id, $form_state);
+function rebuild_form($form_id, &$form_state, $old_form = NULL) {
+  $form = retrieve_form($form_id, $form_state);
 
   // If only parts of the form will be returned to the browser (e.g., Ajax or
   // RIA clients), re-use the old #build_id to not require client-side code to
@@ -448,12 +449,12 @@ function drupal_rebuild_form($form_id, &$form_state, $old_form = NULL) {
   // Otherwise, a new #build_id is generated, to not clobber the previous
   // build's data in the form cache; also allowing the user to go back to an
   // earlier build, make changes, and re-submit.
-  // @see drupal_prepare_form()
+  // @see prepare_form()
   if (isset($old_form['#build_id']) && !empty($form_state['rebuild_info']['copy']['#build_id'])) {
     $form['#build_id'] = $old_form['#build_id'];
   }
   else {
-    $form['#build_id'] = 'form-' . drupal_hash_base64(uniqid(mt_rand(), TRUE) . mt_rand());
+    $form['#build_id'] = 'form-' . hash_base64(uniqid(mt_rand(), TRUE) . mt_rand());
   }
 
   // #action defaults to request_uri(), but in case of Ajax and other partial
@@ -463,9 +464,9 @@ function drupal_rebuild_form($form_id, &$form_state, $old_form = NULL) {
     $form['#action'] = $old_form['#action'];
   }
 
-  drupal_prepare_form($form_id, $form, $form_state);
+  prepare_form($form_id, $form, $form_state);
 
-  // Caching is normally done in drupal_process_form(), but what needs to be
+  // Caching is normally done in process_form(), but what needs to be
   // cached is the $form structure before it passes through form_builder(),
   // so we need to do it here.
   // @todo For Drupal 8, find a way to avoid this code duplication.
@@ -489,7 +490,7 @@ function form_get_cache($form_build_id, &$form_state) {
     $form = $cached->data;
 
     global $user;
-    if ((isset($form['#cache_token']) && drupal_valid_token($form['#cache_token'])) || (!isset($form['#cache_token']) && !$user->uid)) {
+    if ((isset($form['#cache_token']) && valid_token($form['#cache_token'])) || (!isset($form['#cache_token']) && !$user->uid)) {
       if ($cached = cache('form')->get('form_state_' . $form_build_id)) {
         // Re-populate $form_state for subsequent rebuilds.
         $form_state = $cached->data + $form_state;
@@ -503,7 +504,7 @@ function form_get_cache($form_build_id, &$form_state) {
             module_load_include($file['type'], $file['module'], $file['name']);
           }
           elseif (file_exists($file)) {
-            require_once DRUPAL_ROOT . '/' . $file;
+            require_once ROOT . '/' . $file;
           }
         }
       }
@@ -522,7 +523,7 @@ function form_set_cache($form_build_id, $form, $form_state) {
   // Cache form structure.
   if (isset($form)) {
     if ($GLOBALS['user']->uid) {
-      $form['#cache_token'] = drupal_get_token();
+      $form['#cache_token'] = get_token();
     }
     cache('form')->set('form_' . $form_build_id, $form, REQUEST_TIME + $expire);
   }
@@ -615,7 +616,7 @@ function form_load_include(&$form_state, $type, $module, $name = NULL) {
  * Retrieves, populates, and processes a form.
  *
  * This function allows you to supply values for form elements and submit a
- * form for processing. Compare to drupal_get_form(), which also builds and
+ * form for processing. Compare to get_form(), which also builds and
  * processes a form, but does not allow you to supply values.
  *
  * There is no return value, but you can check to see if there are errors
@@ -638,7 +639,7 @@ function form_load_include(&$form_state, $type, $module, $name = NULL) {
  *   value to NULL.
  * @param ...
  *   Any additional arguments are passed on to the functions called by
- *   drupal_form_submit(), including the unique form constructor function.
+ *   form_submit(), including the unique form constructor function.
  *   For example, the node_edit form requires that a node object be passed
  *   in here when it is called. Arguments that need to be passed by reference
  *   should not be included here, but rather placed directly in the $form_state
@@ -648,11 +649,11 @@ function form_load_include(&$form_state, $type, $module, $name = NULL) {
  *   function mymodule_form($form, &$form_state, &$object) {
  *   }
  *   @endcode
- *   would be called via drupal_form_submit() as follows:
+ *   would be called via form_submit() as follows:
  *   @code
  *   $form_state['values'] = $my_form_values;
  *   $form_state['build_info']['args'] = array(&$object);
- *   drupal_form_submit('mymodule_form', $form_state);
+ *   form_submit('mymodule_form', $form_state);
  *   @endcode
  * For example:
  * @code
@@ -663,10 +664,10 @@ function form_load_include(&$form_state, $type, $module, $name = NULL) {
  * $form_state['values']['pass']['pass1'] = 'password';
  * $form_state['values']['pass']['pass2'] = 'password';
  * $form_state['values']['op'] = t('Create new account');
- * drupal_form_submit('user_register_form', $form_state);
+ * form_submit('user_register_form', $form_state);
  * @endcode
  */
-function drupal_form_submit($form_id, &$form_state) {
+function form_submit($form_id, &$form_state) {
   if (!isset($form_state['build_info']['args'])) {
     $args = func_get_args();
     array_shift($args);
@@ -677,13 +678,13 @@ function drupal_form_submit($form_id, &$form_state) {
   $form_state += form_state_defaults();
 
   // Populate $form_state['input'] with the submitted values before retrieving
-  // the form, to be consistent with what drupal_build_form() does for
+  // the form, to be consistent with what build_form() does for
   // non-programmatic submissions (form builder functions may expect it to be
   // there).
   $form_state['input'] = $form_state['values'];
 
   $form_state['programmed'] = TRUE;
-  $form = drupal_retrieve_form($form_id, $form_state);
+  $form = retrieve_form($form_id, $form_state);
   // Programmed forms are always submitted.
   $form_state['submitted'] = TRUE;
 
@@ -691,8 +692,8 @@ function drupal_form_submit($form_id, &$form_state) {
   $form_state['must_validate'] = TRUE;
   form_clear_error();
 
-  drupal_prepare_form($form_id, $form, $form_state);
-  drupal_process_form($form_id, $form, $form_state);
+  prepare_form($form_id, $form, $form_state);
+  process_form($form_id, $form, $form_state);
 }
 
 /**
@@ -706,10 +707,10 @@ function drupal_form_submit($form_id, &$form_state) {
  *   different $form_id values to the proper form constructor function.
  * @param $form_state
  *   A keyed array containing the current state of the form, including the
- *   additional arguments to drupal_get_form() or drupal_form_submit() in the
+ *   additional arguments to get_form() or form_submit() in the
  *   'args' component of the array.
  */
-function drupal_retrieve_form($form_id, &$form_state) {
+function retrieve_form($form_id, &$form_state) {
   $forms = &drupal_static(__FUNCTION__);
 
   // Record the filepath of the include file containing the original form, so
@@ -733,7 +734,7 @@ function drupal_retrieve_form($form_id, &$form_state) {
 
   // We first check to see if there's a function named after the $form_id.
   // If there is, we simply pass the arguments on to it to get the form.
-  if (!function_exists($form_id)) {
+  if (!function_exists('Drupal\\' . $form_id)) {
     // In cases where many form_ids need to share a central constructor function,
     // such as the node editing form, modules can implement hook_forms(). It
     // maps one or more form_ids to the correct constructor functions.
@@ -765,12 +766,12 @@ function drupal_retrieve_form($form_id, &$form_state) {
 
   $form = array();
   // Assign a default CSS class name based on $form_id.
-  // This happens here and not in drupal_prepare_form() in order to allow the
+  // This happens here and not in prepare_form() in order to allow the
   // form constructor function to override or remove the default class.
-  $form['#attributes']['class'][] = drupal_html_class($form_id);
+  $form['#attributes']['class'][] = html_class($form_id);
   // Same for the base form ID, if any.
   if (isset($form_state['build_info']['base_form_id'])) {
-    $form['#attributes']['class'][] = drupal_html_class($form_state['build_info']['base_form_id']);
+    $form['#attributes']['class'][] = html_class($form_state['build_info']['base_form_id']);
   }
 
   // We need to pass $form_state by reference in order for forms to modify it,
@@ -778,21 +779,21 @@ function drupal_retrieve_form($form_id, &$form_state) {
   // explicitly.
   $args = array_merge(array($form, &$form_state), $args);
 
-  // When the passed $form_state (not using drupal_get_form()) defines a
+  // When the passed $form_state (not using get_form()) defines a
   // 'wrapper_callback', then it requests to invoke a separate (wrapping) form
   // builder function to pre-populate the $form array with form elements, which
   // the actual form builder function ($callback) expects. This allows for
   // pre-populating a form with common elements for certain forms, such as
-  // back/next/save buttons in multi-step form wizards. See drupal_build_form().
+  // back/next/save buttons in multi-step form wizards. See build_form().
   if (isset($form_state['wrapper_callback'])) {
-    $form = call_user_func_array($form_state['wrapper_callback'], $args);
+    $form = call_user_func_array('Drupal\\' . $form_state['wrapper_callback'], $args);
     // Put the prepopulated $form into $args.
     $args[0] = $form;
   }
 
   // If $callback was returned by a hook_forms() implementation, call it.
   // Otherwise, call the function named after the form id.
-  $form = call_user_func_array(isset($callback) ? $callback : $form_id, $args);
+  $form = call_user_func_array('Drupal\\' . (isset($callback) ? $callback : $form_id), $args);
   $form['#form_id'] = $form_id;
 
   return $form;
@@ -815,7 +816,7 @@ function drupal_retrieve_form($form_id, &$form_state) {
  *   multi-step form. Additional information, like the sanitized $_POST
  *   data, is also accumulated here.
  */
-function drupal_process_form($form_id, &$form, &$form_state) {
+function process_form($form_id, &$form, &$form_state) {
   $form_state['values'] = array();
 
   // With $_GET, these forms are always submitted if requested.
@@ -827,7 +828,7 @@ function drupal_process_form($form_id, &$form, &$form_state) {
       $form_state['input']['form_id'] = $form_id;
     }
     if (!isset($form_state['input']['form_token']) && isset($form['#token'])) {
-      $form_state['input']['form_token'] = drupal_get_token($form['#token']);
+      $form_state['input']['form_token'] = get_token($form['#token']);
     }
   }
 
@@ -840,14 +841,14 @@ function drupal_process_form($form_id, &$form, &$form_state) {
 
   // Only process the input if we have a correct form submission.
   if ($form_state['process_input']) {
-    drupal_validate_form($form_id, $form, $form_state);
+    validate_form($form_id, $form, $form_state);
 
-    // drupal_html_id() maintains a cache of element IDs it has seen,
+    // html_id() maintains a cache of element IDs it has seen,
     // so it can prevent duplicates. We want to be sure we reset that
     // cache when a form is processed, so scenarios that result in
     // the form being built behind the scenes and again for the
     // browser don't increment all the element IDs needlessly.
-    drupal_static_reset('drupal_html_id');
+    drupal_static_reset('Drupal\html_id');
 
     if ($form_state['submitted'] && !form_get_errors() && !$form_state['rebuild']) {
       // Execute form submit handlers.
@@ -864,7 +865,7 @@ function drupal_process_form($form_id, &$form, &$form_state) {
       // If batches were set in the submit handlers, we process them now,
       // possibly ending execution. We make sure we do not react to the batch
       // that is already being processed (if a batch operation performs a
-      // drupal_form_submit).
+      // form_submit).
       if ($batch =& batch_get() && !isset($batch['current_set'])) {
         // Store $form_state information in the batch definition.
         // We need the full $form_state when either:
@@ -872,7 +873,7 @@ function drupal_process_form($form_id, &$form, &$form_state) {
         //   processing. See form_execute_handlers().
         // - The form is multistep.
         // In other cases, we only need the information expected by
-        // drupal_redirect_form().
+        // redirect_form().
         if ($batch['has_form_submits'] || !empty($form_state['rebuild'])) {
           $batch['form_state'] = $form_state;
         }
@@ -893,10 +894,10 @@ function drupal_process_form($form_id, &$form, &$form_state) {
       $form_state['executed'] = TRUE;
 
       // Redirect the form based on values in $form_state.
-      drupal_redirect_form($form_state);
+      redirect_form($form_state);
     }
 
-    // Don't rebuild or cache form submissions invoked via drupal_form_submit().
+    // Don't rebuild or cache form submissions invoked via form_submit().
     if (!empty($form_state['programmed'])) {
       return;
     }
@@ -921,7 +922,7 @@ function drupal_process_form($form_id, &$form, &$form_state) {
       // may use $form_state['rebuild'] to determine if they are running in the
       // context of a rebuild, so ensure it is set.
       $form_state['rebuild'] = TRUE;
-      $form = drupal_rebuild_form($form_id, $form_state, $form);
+      $form = rebuild_form($form_id, $form_state, $form);
     }
   }
 
@@ -930,7 +931,7 @@ function drupal_process_form($form_id, &$form, &$form_state) {
   // shall be cached. But the form may only be cached if the 'no_cache' property
   // is not set to TRUE. Only cache $form as it was prior to form_builder(),
   // because form_builder() must run for each request to accommodate new user
-  // input. Rebuilt forms are not cached here, because drupal_rebuild_form()
+  // input. Rebuilt forms are not cached here, because rebuild_form()
   // already takes care of that.
   if (!$form_state['rebuild'] && $form_state['cache'] && empty($form_state['no_cache'])) {
     form_set_cache($form['#build_id'], $unprocessed_form, $form_state);
@@ -951,7 +952,7 @@ function drupal_process_form($form_id, &$form, &$form_state) {
  *   A keyed array containing the current state of the form. Passed
  *   in here so that hook_form_alter() calls can use it, as well.
  */
-function drupal_prepare_form($form_id, &$form, &$form_state) {
+function prepare_form($form_id, &$form, &$form_state) {
   global $user;
 
   $form['#type'] = 'form';
@@ -966,10 +967,10 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
   // form_build_id is used as key to cache a particular build of the form. For
   // multi-step forms, this allows the user to go back to an earlier build, make
   // changes, and re-submit.
-  // @see drupal_build_form()
-  // @see drupal_rebuild_form()
+  // @see build_form()
+  // @see rebuild_form()
   if (!isset($form['#build_id'])) {
-    $form['#build_id'] = 'form-' . drupal_hash_base64(uniqid(mt_rand(), TRUE) . mt_rand());
+    $form['#build_id'] = 'form-' . hash_base64(uniqid(mt_rand(), TRUE) . mt_rand());
   }
   $form['form_build_id'] = array(
     '#type' => 'hidden',
@@ -996,9 +997,9 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
     else {
       $form['#token'] = $form_id;
       $form['form_token'] = array(
-        '#id' => drupal_html_id('edit-' . $form_id . '-form-token'),
+        '#id' => html_id('edit-' . $form_id . '-form-token'),
         '#type' => 'token',
-        '#default_value' => drupal_get_token($form['#token']),
+        '#default_value' => get_token($form['#token']),
       );
     }
   }
@@ -1007,11 +1008,11 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
     $form['form_id'] = array(
       '#type' => 'hidden',
       '#value' => $form_id,
-      '#id' => drupal_html_id("edit-$form_id"),
+      '#id' => html_id("edit-$form_id"),
     );
   }
   if (!isset($form['#id'])) {
-    $form['#id'] = drupal_html_id($form_id);
+    $form['#id'] = html_id($form_id);
   }
 
   $form += element_info('form');
@@ -1021,12 +1022,12 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
     // Ensure that modules can rely on #validate being set.
     $form['#validate'] = array();
     // Check for a handler specific to $form_id.
-    if (function_exists($form_id . '_validate')) {
+    if (function_exists('Drupal\\' . $form_id . '_validate')) {
       $form['#validate'][] = $form_id . '_validate';
     }
     // Otherwise check whether this is a shared form and whether there is a
     // handler for the shared $form_id.
-    elseif (isset($form_state['build_info']['base_form_id']) && function_exists($form_state['build_info']['base_form_id'] . '_validate')) {
+    elseif (isset($form_state['build_info']['base_form_id']) && function_exists('Drupal\\' . $form_state['build_info']['base_form_id'] . '_validate')) {
       $form['#validate'][] = $form_state['build_info']['base_form_id'] . '_validate';
     }
   }
@@ -1035,12 +1036,12 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
     // Ensure that modules can rely on #submit being set.
     $form['#submit'] = array();
     // Check for a handler specific to $form_id.
-    if (function_exists($form_id . '_submit')) {
+    if (function_exists('Drupal\\' . $form_id . '_submit')) {
       $form['#submit'][] = $form_id . '_submit';
     }
     // Otherwise check whether this is a shared form and whether there is a
     // handler for the shared $form_id.
-    elseif (isset($form_state['build_info']['base_form_id']) && function_exists($form_state['build_info']['base_form_id'] . '_submit')) {
+    elseif (isset($form_state['build_info']['base_form_id']) && function_exists('Drupal\\' . $form_state['build_info']['base_form_id'] . '_submit')) {
       $form['#submit'][] = $form_state['build_info']['base_form_id'] . '_submit';
     }
   }
@@ -1063,7 +1064,7 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
     $hooks[] = 'form_' . $form_state['build_info']['base_form_id'];
   }
   $hooks[] = 'form_' . $form_id;
-  drupal_alter($hooks, $form, $form_state, $form_id);
+  alter($hooks, $form, $form_state, $form_id);
 }
 
 
@@ -1093,19 +1094,19 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
  *   web service requests, or other expensive requests that should
  *   not be repeated in the submission step.
  */
-function drupal_validate_form($form_id, &$form, &$form_state) {
+function validate_form($form_id, &$form, &$form_state) {
   $validated_forms = &drupal_static(__FUNCTION__, array());
 
   if (isset($validated_forms[$form_id]) && empty($form_state['must_validate'])) {
     return;
   }
 
-  // If the session token was set by drupal_prepare_form(), ensure that it
+  // If the session token was set by prepare_form(), ensure that it
   // matches the current user's session.
   if (isset($form['#token'])) {
-    if (!drupal_valid_token($form_state['values']['form_token'], $form['#token'])) {
+    if (!valid_token($form_state['values']['form_token'], $form['#token'])) {
       $path = current_path();
-      $query = drupal_get_query_parameters();
+      $query = get_query_parameters();
       $url = url($path, array('query' => $query));
 
       // Setting this error will cause the form to fail validation.
@@ -1124,9 +1125,9 @@ function drupal_validate_form($form_id, &$form, &$form_state) {
       // If the section exists within $form_state['values'], even if the value
       // is NULL, copy it to $values.
       $section_exists = NULL;
-      $value = drupal_array_get_nested_value($form_state['values'], $section, $section_exists);
+      $value = array_get_nested_value($form_state['values'], $section, $section_exists);
       if ($section_exists) {
-        drupal_array_set_nested_value($values, $section, $value);
+        array_set_nested_value($values, $section, $value);
       }
     }
     // A button's #value does not require validation, so for convenience we
@@ -1140,8 +1141,8 @@ function drupal_validate_form($form_id, &$form, &$form_state) {
       // dictated by #parents. If it is, copy it to $values, but do not override
       // what may already be in $values.
       $parents = $form_state['triggering_element']['#parents'];
-      if (!drupal_array_nested_key_exists($values, $parents) && drupal_array_get_nested_value($form_state['values'], $parents) === $button_value) {
-        drupal_array_set_nested_value($values, $parents, $button_value);
+      if (!array_nested_key_exists($values, $parents) && array_get_nested_value($form_state['values'], $parents) === $button_value) {
+        array_set_nested_value($values, $parents, $button_value);
       }
 
       // Additionally, form_builder() places the button value in
@@ -1164,7 +1165,7 @@ function drupal_validate_form($form_id, &$form, &$form_state) {
  * is redirected. By default, we redirect to a new destination page. The path
  * of the destination page can be set in $form_state['redirect'], as either a
  * string containing the destination or an array of arguments compatible with
- * drupal_goto(). If that is not set, the user is redirected to the current
+ * redirect(). If that is not set, the user is redirected to the current
  * page to display a fresh, unpopulated copy of the form.
  *
  * For example, to redirect to 'node':
@@ -1187,10 +1188,10 @@ function drupal_validate_form($form_id, &$form, &$form_state) {
  * There are several triggers that may prevent a redirection though:
  * - If $form_state['redirect'] is FALSE, a form builder function or form
  *   validation/submit handler does not want a user to be redirected, which
- *   means that drupal_goto() is not invoked. For most forms, the redirection
+ *   means that redirect() is not invoked. For most forms, the redirection
  *   logic will be the same regardless of whether $form_state['redirect'] is
  *   undefined or FALSE. However, in case it was not defined and the current
- *   request contains a 'destination' query string, drupal_goto() will redirect
+ *   request contains a 'destination' query string, redirect() will redirect
  *   to that given destination instead. Only setting $form_state['redirect'] to
  *   FALSE will prevent any redirection.
  * - If $form_state['no_redirect'] is TRUE, then the callback that originally
@@ -1200,19 +1201,19 @@ function drupal_validate_form($form_id, &$form, &$form_state) {
  *   callback to prevent any redirection. $form_state['no_redirect'] should NOT
  *   be altered by form builder functions or form validation/submit handlers.
  * - If $form_state['programmed'] is TRUE, the form submission was usually
- *   invoked via drupal_form_submit(), so any redirection would break the script
- *   that invoked drupal_form_submit().
+ *   invoked via form_submit(), so any redirection would break the script
+ *   that invoked form_submit().
  * - If $form_state['rebuild'] is TRUE, the form needs to be rebuilt without
  *   redirection.
  *
  * @param $form_state
  *   A keyed array containing the current state of the form.
  *
- * @see drupal_process_form()
- * @see drupal_build_form()
+ * @see process_form()
+ * @see build_form()
  */
-function drupal_redirect_form($form_state) {
-  // Skip redirection for form submissions invoked via drupal_form_submit().
+function redirect_form($form_state) {
+  // Skip redirection for form submissions invoked via form_submit().
   if (!empty($form_state['programmed'])) {
     return;
   }
@@ -1224,21 +1225,21 @@ function drupal_redirect_form($form_state) {
   if (!empty($form_state['no_redirect'])) {
     return;
   }
-  // Only invoke drupal_goto() if redirect value was not set to FALSE.
+  // Only invoke redirect() if redirect value was not set to FALSE.
   if (!isset($form_state['redirect']) || $form_state['redirect'] !== FALSE) {
     if (isset($form_state['redirect'])) {
       if (is_array($form_state['redirect'])) {
-        call_user_func_array('drupal_goto', $form_state['redirect']);
+        call_user_func_array('Drupal\redirect', $form_state['redirect']);
       }
       else {
         // This function can be called from the installer, which guarantees
         // that $redirect will always be a string, so catch that case here
         // and use the appropriate redirect function.
-        $function = drupal_installation_attempted() ? 'install_goto' : 'drupal_goto';
+        $function = installation_attempted() ? 'Drupal\install_redirect' : 'Drupal\redirect';
         $function($form_state['redirect']);
       }
     }
-    drupal_goto($_GET['q']);
+    redirect($_GET['q']);
   }
 }
 
@@ -1349,7 +1350,7 @@ function _form_validate(&$elements, &$form_state, $form_id = NULL) {
     // end of this function, doing it here is only to handle the rare edge case
     // where a validate handler invokes form processing of another form.
     else {
-      drupal_static_reset('form_set_error:limit_validation_errors');
+      drupal_static_reset('Drupal\form_set_error:limit_validation_errors');
     }
 
     // Make sure a value is passed when the field is required.
@@ -1384,6 +1385,7 @@ function _form_validate(&$elements, &$form_state, $form_id = NULL) {
     // #value data.
     elseif (isset($elements['#element_validate'])) {
       foreach ($elements['#element_validate'] as $function) {
+        $function = 'Drupal\\' . $function;
         $function($elements, $form_state, $form_state['complete_form']);
       }
     }
@@ -1393,7 +1395,7 @@ function _form_validate(&$elements, &$form_state, $form_id = NULL) {
   // Done validating this element, so turn off error suppression.
   // _form_validate() turns it on again when starting on the next element, if
   // it's still appropriate to do so.
-  drupal_static_reset('form_set_error:limit_validation_errors');
+  drupal_static_reset('Drupal\form_set_error:limit_validation_errors');
 }
 
 /**
@@ -1428,7 +1430,7 @@ function form_execute_handlers($type, &$form, &$form_state) {
   foreach ($handlers as $function) {
     // Check if a previous _submit handler has set a batch, but make sure we
     // do not react to a batch that is already being processed (for instance
-    // if a batch operation performs a drupal_form_submit()).
+    // if a batch operation performs a form_submit()).
     if ($type == 'submit' && ($batch =& batch_get()) && !isset($batch['id'])) {
       // Some previous submit handler has set a batch. To ensure correct
       // execution order, store the call in a special 'control' batch set.
@@ -1437,6 +1439,7 @@ function form_execute_handlers($type, &$form, &$form_state) {
       $batch['has_form_submits'] = TRUE;
     }
     else {
+      $function = 'Drupal\\' . $function;
       $function($form, $form_state);
     }
     $return = TRUE;
@@ -1574,7 +1577,7 @@ function form_set_error($name = NULL, $message = '', $limit_validation_errors =
     if ($record) {
       $form[$name] = $message;
       if ($message) {
-        drupal_set_message($message, 'error');
+        set_message($message, 'error');
       }
     }
   }
@@ -1586,7 +1589,7 @@ function form_set_error($name = NULL, $message = '', $limit_validation_errors =
  * Clear all errors against all form elements made by form_set_error().
  */
 function form_clear_error() {
-  drupal_static_reset('form_set_error');
+  drupal_static_reset('Drupal\form_set_error');
 }
 
 /**
@@ -1631,7 +1634,7 @@ function form_error(&$element, $message = '') {
  *
  * This is one of the three primary functions that recursively iterates a form
  * array. This one does it for completing the form building process. The other
- * two are _form_validate() (invoked via drupal_validate_form() and used to
+ * two are _form_validate() (invoked via validate_form() and used to
  * invoke validation logic for each element) and drupal_render() (for rendering
  * each element). Each of these three pipelines provides ample opportunity for
  * modules to customize what happens. For example, during this function's life
@@ -1672,14 +1675,14 @@ function form_error(&$element, $message = '') {
  * As stated above, each element's #process functions are executed after its
  * #value has been set. This enables those functions to execute conditional
  * logic based on the current value. However, all of form_builder() runs before
- * drupal_validate_form() is called, so during #process function execution, the
+ * validate_form() is called, so during #process function execution, the
  * element's #value has not yet been validated, so any code that requires
  * validated values must reside within a submit handler.
  *
  * As a security measure, user input is used for an element's #value only if the
  * element exists within $form, is not disabled (as per the #disabled property),
  * and can be accessed (as per the #access property, except that forms submitted
- * using drupal_form_submit() bypass #access restrictions). When user input is
+ * using form_submit() bypass #access restrictions). When user input is
  * ignored due to #disabled and #access restrictions, the element's default
  * value is used.
  *
@@ -1747,7 +1750,7 @@ function form_builder($form_id, &$element, &$form_state) {
     $form_state['complete_form'] = &$element;
 
     // Set a flag if we have a correct form submission. This is always TRUE for
-    // programmed forms coming from drupal_form_submit(), or if the form_id coming
+    // programmed forms coming from form_submit(), or if the form_id coming
     // from the POST data is set and matches the current form_id.
     if ($form_state['programmed'] || (!empty($form_state['input']) && (isset($form_state['input']['form_id']) && ($form_state['input']['form_id'] == $form_id)))) {
       $form_state['process_input'] = TRUE;
@@ -1761,7 +1764,7 @@ function form_builder($form_id, &$element, &$form_state) {
   }
 
   if (!isset($element['#id'])) {
-    $element['#id'] = drupal_html_id('edit-' . implode('-', $element['#parents']));
+    $element['#id'] = html_id('edit-' . implode('-', $element['#parents']));
   }
   // Handle input elements.
   if (!empty($element['#input'])) {
@@ -1771,7 +1774,8 @@ function form_builder($form_id, &$element, &$form_state) {
   // checkboxes and files.
   if (isset($element['#process']) && !$element['#processed']) {
     foreach ($element['#process'] as $process) {
-      $element = $process($element, $form_state, $form_state['complete_form']);
+      $function = 'Drupal\\' . $process;
+      $element = $function($element, $form_state, $form_state['complete_form']);
     }
     $element['#processed'] = TRUE;
   }
@@ -1835,6 +1839,7 @@ function form_builder($form_id, &$element, &$form_state) {
   // after normal input parsing has been completed.
   if (isset($element['#after_build']) && !isset($element['#after_build_done'])) {
     foreach ($element['#after_build'] as $function) {
+      $function = 'Drupal\\' . $function;
       $element = $function($element, $form_state);
     }
     $element['#after_build_done'] = TRUE;
@@ -1948,20 +1953,20 @@ function _form_builder_handle_input_element($form_id, &$element, &$form_state) {
   // elements with #access=FALSE or #disabled=TRUE. For security, these must
   // not be processed. Forms that set #disabled=TRUE on an element do not
   // expect input for the element, and even forms submitted with
-  // drupal_form_submit() must not be able to get around this. Forms that set
+  // form_submit() must not be able to get around this. Forms that set
   // #access=FALSE on an element usually allow access for some users, so forms
-  // submitted with drupal_form_submit() may bypass access restriction and be
+  // submitted with form_submit() may bypass access restriction and be
   // treated as high-privilege users instead.
   $process_input = empty($element['#disabled']) && ($form_state['programmed'] || ($form_state['process_input'] && (!isset($element['#access']) || $element['#access'])));
 
   // Set the element's #value property.
   if (!isset($element['#value']) && !array_key_exists('#value', $element)) {
-    $value_callback = !empty($element['#value_callback']) ? $element['#value_callback'] : 'form_type_' . $element['#type'] . '_value';
+    $value_callback = 'Drupal\\' . (!empty($element['#value_callback']) ? $element['#value_callback'] : 'form_type_' . $element['#type'] . '_value');
     if ($process_input) {
       // Get the input for the current element. NULL values in the input need to
       // be explicitly distinguished from missing input. (see below)
       $input_exists = NULL;
-      $input = drupal_array_get_nested_value($form_state['input'], $element['#parents'], $input_exists);
+      $input = array_get_nested_value($form_state['input'], $element['#parents'], $input_exists);
       // For browser-submitted forms, the submitted values do not contain values
       // for certain elements (empty multiple select, unchecked checkbox).
       // During initial form processing, we add explicit NULL values for such
@@ -1969,12 +1974,12 @@ function _form_builder_handle_input_element($form_id, &$element, &$form_state) {
       // distinguish elements having NULL input from elements that were not part
       // of the initially submitted form and can therefore use default values
       // for the latter, if required. Programmatically submitted forms can
-      // submit explicit NULL values when calling drupal_form_submit(), so we do
+      // submit explicit NULL values when calling form_submit(), so we do
       // not modify $form_state['input'] for them.
       if (!$input_exists && !$form_state['rebuild'] && !$form_state['programmed']) {
         // Add the necessary parent keys to $form_state['input'] and sets the
         // element's input value to NULL.
-        drupal_array_set_nested_value($form_state['input'], $element['#parents'], NULL);
+        array_set_nested_value($form_state['input'], $element['#parents'], NULL);
         $input_exists = TRUE;
       }
       // If we have input for the current element, assign it to the #value
@@ -2033,7 +2038,7 @@ function _form_builder_handle_input_element($form_id, &$element, &$form_state) {
 
   // Set the element's value in $form_state['values'], but only, if its key
   // does not exist yet (a #value_callback may have already populated it).
-  if (!drupal_array_nested_key_exists($form_state['values'], $element['#parents'])) {
+  if (!array_nested_key_exists($form_state['values'], $element['#parents'])) {
     form_set_value($element, $element['#value'], $form_state);
   }
 }
@@ -2146,7 +2151,7 @@ function form_state_values_clean(&$form_state) {
     $parents = $button['#parents'];
     $last_parent = array_pop($parents);
     $key_exists = NULL;
-    $values = &drupal_array_get_nested_value($form_state['values'], $parents, $key_exists);
+    $values = &array_get_nested_value($form_state['values'], $parents, $key_exists);
     if ($key_exists && is_array($values)) {
       unset($values[$last_parent]);
     }
@@ -2263,7 +2268,7 @@ function form_type_checkboxes_value($element, $input = FALSE) {
   }
   elseif (is_array($input)) {
     // Programmatic form submissions use NULL to indicate that a checkbox
-    // should be unchecked; see drupal_form_submit(). We therefore remove all
+    // should be unchecked; see form_submit(). We therefore remove all
     // NULL elements from the array before constructing the return value, to
     // simulate the behavior of web browsers (which do not send unchecked
     // checkboxes to the server at all). This will not affect non-programmatic
@@ -2273,7 +2278,7 @@ function form_type_checkboxes_value($element, $input = FALSE) {
         unset($input[$key]);
       }
     }
-    return drupal_map_assoc($input);
+    return map_assoc($input);
   }
   else {
     return array();
@@ -2310,7 +2315,7 @@ function form_type_tableselect_value($element, $input = FALSE) {
       return $value;
     }
     else {
-      return is_array($input) ? drupal_map_assoc($input) : array();
+      return is_array($input) ? map_assoc($input) : array();
     }
   }
 }
@@ -2354,7 +2359,7 @@ function form_type_select_value($element, $input = FALSE) {
       // unselected. A disabled multi-select always submits NULL, and the
       // default value should be used.
       if (empty($element['#disabled'])) {
-        return (is_array($input)) ? drupal_map_assoc($input) : array();
+        return (is_array($input)) ? map_assoc($input) : array();
       }
       else {
         return (isset($element['#default_value']) && is_array($element['#default_value'])) ? $element['#default_value'] : array();
@@ -2441,7 +2446,7 @@ function form_type_token_value($element, $input = FALSE) {
  *   Form state array where the value change should be recorded.
  */
 function form_set_value($element, $value, &$form_state) {
-  drupal_array_set_nested_value($form_state['values'], $element['#parents'], $value, TRUE);
+  array_set_nested_value($form_state['values'], $element['#parents'], $value, TRUE);
 }
 
 /**
@@ -2459,7 +2464,7 @@ function form_set_value($element, $value, &$form_state) {
  */
 function form_options_flatten($array) {
   // Always reset static var when first entering the recursion.
-  drupal_static_reset('_form_options_flatten');
+  drupal_static_reset('Drupal\_form_options_flatten');
   return _form_options_flatten($array);
 }
 
@@ -2574,7 +2579,7 @@ function theme_select($variables) {
   element_set_attributes($element, array('id', 'name', 'size'));
   _form_set_class($element, array('form-select'));
 
-  return '<select' . drupal_attributes($element['#attributes']) . '>' . form_select_options($element) . '</select>';
+  return '<select' . attributes($element['#attributes']) . '>' . form_select_options($element) . '</select>';
 }
 
 /**
@@ -2687,7 +2692,7 @@ function theme_fieldset($variables) {
   element_set_attributes($element, array('id'));
   _form_set_class($element, array('form-wrapper'));
 
-  $output = '<fieldset' . drupal_attributes($element['#attributes']) . '>';
+  $output = '<fieldset' . attributes($element['#attributes']) . '>';
   if (!empty($element['#title'])) {
     // Always wrap fieldset legends in a SPAN for CSS positioning.
     $output .= '<legend><span class="fieldset-legend">' . $element['#title'] . '</span></legend>';
@@ -2709,7 +2714,7 @@ function theme_fieldset($variables) {
  * Returns HTML for a radio button form element.
  *
  * Note: The input "name" attribute needs to be sanitized before output, which
- *       is currently done by passing all attributes to drupal_attributes().
+ *       is currently done by passing all attributes to attributes().
  *
  * @param $variables
  *   An associative array containing:
@@ -2729,7 +2734,7 @@ function theme_radio($variables) {
   }
   _form_set_class($element, array('form-radio'));
 
-  return '<input' . drupal_attributes($element['#attributes']) . ' />';
+  return '<input' . attributes($element['#attributes']) . ' />';
 }
 
 /**
@@ -2753,7 +2758,7 @@ function theme_radios($variables) {
   if (!empty($element['#attributes']['class'])) {
     $attributes['class'] .= ' ' . implode(' ', $element['#attributes']['class']);
   }
-  return '<div' . drupal_attributes($attributes) . '>' . (!empty($element['#children']) ? $element['#children'] : '') . '</div>';
+  return '<div' . attributes($attributes) . '>' . (!empty($element['#children']) ? $element['#children'] : '') . '</div>';
 }
 
 /**
@@ -2832,7 +2837,7 @@ function theme_date($variables) {
   }
   $attributes['class'][] = 'container-inline';
 
-  return '<div' . drupal_attributes($attributes) . '>' . drupal_render_children($element) . '</div>';
+  return '<div' . attributes($attributes) . '>' . render_children($element) . '</div>';
 }
 
 /**
@@ -2863,17 +2868,17 @@ function form_process_date($element) {
   foreach ($order as $type) {
     switch ($type) {
       case 'day':
-        $options = drupal_map_assoc(range(1, 31));
+        $options = map_assoc(range(1, 31));
         $title = t('Day');
         break;
 
       case 'month':
-        $options = drupal_map_assoc(range(1, 12), 'map_month');
+        $options = map_assoc(range(1, 12), 'Drupal\map_month');
         $title = t('Month');
         break;
 
       case 'year':
-        $options = drupal_map_assoc(range(1900, 2050));
+        $options = map_assoc(range(1900, 2050));
         $title = t('Year');
         break;
     }
@@ -2901,7 +2906,7 @@ function date_validate($element) {
 }
 
 /**
- * Helper function for usage with drupal_map_assoc to display month names.
+ * Helper function for usage with map_assoc to display month names.
  */
 function map_month($month) {
   $months = &drupal_static(__FUNCTION__, array(
@@ -2953,13 +2958,13 @@ function form_process_radios($element) {
       $element[$key] += array(
         '#type' => 'radio',
         '#title' => $choice,
-        // The key is sanitized in drupal_attributes() during output from the
+        // The key is sanitized in attributes() during output from the
         // theme function.
         '#return_value' => $key,
         '#default_value' => isset($element['#default_value']) ? $element['#default_value'] : NULL,
         '#attributes' => $element['#attributes'],
         '#parents' => $element['#parents'],
-        '#id' => drupal_html_id('edit-' . implode('-', $parents_for_id)),
+        '#id' => html_id('edit-' . implode('-', $parents_for_id)),
         '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
         '#weight' => $weight,
       );
@@ -2991,7 +2996,7 @@ function theme_checkbox($variables) {
   }
   _form_set_class($element, array('form-checkbox'));
 
-  return '<input' . drupal_attributes($element['#attributes']) . ' />';
+  return '<input' . attributes($element['#attributes']) . ' />';
 }
 
 /**
@@ -3014,7 +3019,7 @@ function theme_checkboxes($variables) {
   if (!empty($element['#attributes']['class'])) {
     $attributes['class'] = array_merge($attributes['class'], $element['#attributes']['class']);
   }
-  return '<div' . drupal_attributes($attributes) . '>' . (!empty($element['#children']) ? $element['#children'] : '') . '</div>';
+  return '<div' . attributes($attributes) . '>' . (!empty($element['#children']) ? $element['#children'] : '') . '</div>';
 }
 
 /**
@@ -3132,7 +3137,7 @@ function form_process_actions($element, &$form_state) {
 function form_process_container($element, &$form_state) {
   // Generate the ID of the element if it's not explicitly given.
   if (!isset($element['#id'])) {
-    $element['#id'] = drupal_html_id(implode('-', $element['#parents']) . '-wrapper');
+    $element['#id'] = html_id(implode('-', $element['#parents']) . '-wrapper');
   }
   return $element;
 }
@@ -3164,7 +3169,7 @@ function theme_container($variables) {
     $element['#attributes']['class'][] = 'form-wrapper';
   }
 
-  return '<div' . drupal_attributes($element['#attributes']) . '>' . $element['#children'] . '</div>';
+  return '<div' . attributes($element['#attributes']) . '>' . $element['#children'] . '</div>';
 }
 
 /**
@@ -3223,7 +3228,7 @@ function theme_tableselect($variables) {
     // checkboxes/radios in the first table column.
     if ($element['#js_select']) {
       // Add a "Select all" checkbox.
-      drupal_add_js('core/misc/tableselect.js');
+      add_js('core/misc/tableselect.js');
       array_unshift($header, array('class' => array('select-all')));
     }
     else {
@@ -3294,7 +3299,7 @@ function form_process_tableselect($element) {
             '#default_value' => ($element['#default_value'] == $key) ? $key : NULL,
             '#attributes' => $element['#attributes'],
             '#parents' => $element['#parents'],
-            '#id' => drupal_html_id('edit-' . implode('-', $parents_for_id)),
+            '#id' => html_id('edit-' . implode('-', $parents_for_id)),
             '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
           );
         }
@@ -3373,7 +3378,7 @@ function form_process_machine_name($element, &$form_state) {
   // complete form in $form_state. By reference, because we need to append
   // a #field_suffix that will hold the live preview.
   $key_exists = NULL;
-  $source = drupal_array_get_nested_value($form_state['complete_form'], $element['#machine_name']['source'], $key_exists);
+  $source = array_get_nested_value($form_state['complete_form'], $element['#machine_name']['source'], $key_exists);
   if (!$key_exists) {
     return $element;
   }
@@ -3385,7 +3390,7 @@ function form_process_machine_name($element, &$form_state) {
   $source['#field_suffix'] .= ' <small id="' . $suffix_id . '">&nbsp;</small>';
 
   $parents = array_merge($element['#machine_name']['source'], array('#field_suffix'));
-  drupal_array_set_nested_value($form_state['complete_form'], $parents, $source['#field_suffix']);
+  array_set_nested_value($form_state['complete_form'], $parents, $source['#field_suffix']);
 
   $element['#machine_name']['suffix'] = '#' . $suffix_id;
 
@@ -3434,7 +3439,7 @@ function form_validate_machine_name(&$element, &$form_state) {
 
   // Verify that the machine name is unique.
   if ($element['#default_value'] !== $element['#value']) {
-    $function = $element['#machine_name']['exists'];
+    $function = 'Drupal\\' . $element['#machine_name']['exists'];
     if ($function($element['#value'], $element, $form_state)) {
       form_error($element, t('The machine-readable name is already in use. It must be unique.'));
     }
@@ -3596,7 +3601,7 @@ function form_process_vertical_tabs($element, &$form_state) {
 function theme_vertical_tabs($variables) {
   $element = $variables['element'];
   // Add required JavaScript and Stylesheet.
-  drupal_add_library('system', 'drupal.vertical-tabs');
+  add_library('system', 'drupal.vertical-tabs');
 
   $output = '<h2 class="element-invisible">' . t('Vertical Tabs') . '</h2>';
   $output .= '<div class="vertical-tabs-panes">' . $element['#children'] . '</div>';
@@ -3637,7 +3642,7 @@ function theme_button($variables) {
     $element['#attributes']['class'][] = 'form-button-disabled';
   }
 
-  return '<input' . drupal_attributes($element['#attributes']) . ' />';
+  return '<input' . attributes($element['#attributes']) . ' />';
 }
 
 /**
@@ -3666,7 +3671,7 @@ function theme_image_button($variables) {
     $element['#attributes']['class'][] = 'form-button-disabled';
   }
 
-  return '<input' . drupal_attributes($element['#attributes']) . ' />';
+  return '<input' . attributes($element['#attributes']) . ' />';
 }
 
 /**
@@ -3683,7 +3688,7 @@ function theme_hidden($variables) {
   $element = $variables['element'];
   $element['#attributes']['type'] = 'hidden';
   element_set_attributes($element, array('name', 'value'));
-  return '<input' . drupal_attributes($element['#attributes']) . " />\n";
+  return '<input' . attributes($element['#attributes']) . " />\n";
 }
 
 /**
@@ -3704,8 +3709,8 @@ function theme_textfield($variables) {
   _form_set_class($element, array('form-text'));
 
   $extra = '';
-  if ($element['#autocomplete_path'] && drupal_valid_path($element['#autocomplete_path'])) {
-    drupal_add_library('system', 'drupal.autocomplete');
+  if ($element['#autocomplete_path'] && valid_path($element['#autocomplete_path'])) {
+    add_library('system', 'drupal.autocomplete');
     $element['#attributes']['class'][] = 'form-autocomplete';
 
     $attributes = array();
@@ -3714,10 +3719,10 @@ function theme_textfield($variables) {
     $attributes['value'] = url($element['#autocomplete_path'], array('absolute' => TRUE));
     $attributes['disabled'] = 'disabled';
     $attributes['class'][] = 'autocomplete';
-    $extra = '<input' . drupal_attributes($attributes) . ' />';
+    $extra = '<input' . attributes($attributes) . ' />';
   }
 
-  $output = '<input' . drupal_attributes($element['#attributes']) . ' />';
+  $output = '<input' . attributes($element['#attributes']) . ' />';
 
   return $output . $extra;
 }
@@ -3740,8 +3745,8 @@ function theme_tel($variables) {
   _form_set_class($element, array('form-tel'));
 
   $extra = '';
-  if ($element['#autocomplete_path'] && drupal_valid_path($element['#autocomplete_path'])) {
-    drupal_add_library('system', 'drupal.autocomplete');
+  if ($element['#autocomplete_path'] && valid_path($element['#autocomplete_path'])) {
+    add_library('system', 'drupal.autocomplete');
     $element['#attributes']['class'][] = 'form-autocomplete';
 
     $attributes = array();
@@ -3750,10 +3755,10 @@ function theme_tel($variables) {
     $attributes['value'] = url($element['#autocomplete_path'], array('absolute' => TRUE));
     $attributes['disabled'] = 'disabled';
     $attributes['class'][] = 'autocomplete';
-    $extra = '<input' . drupal_attributes($attributes) . ' />';
+    $extra = '<input' . attributes($attributes) . ' />';
   }
 
-  $output = '<input' . drupal_attributes($element['#attributes']) . ' />';
+  $output = '<input' . attributes($element['#attributes']) . ' />';
 
   return $output . $extra;
 }
@@ -3771,14 +3776,14 @@ function theme_tel($variables) {
 function theme_form($variables) {
   $element = $variables['element'];
   if (isset($element['#action'])) {
-    $element['#attributes']['action'] = drupal_strip_dangerous_protocols($element['#action']);
+    $element['#attributes']['action'] = strip_dangerous_protocols($element['#action']);
   }
   element_set_attributes($element, array('method', 'id'));
   if (empty($element['#attributes']['accept-charset'])) {
     $element['#attributes']['accept-charset'] = "UTF-8";
   }
   // Anonymous DIV to satisfy XHTML compliance.
-  return '<form' . drupal_attributes($element['#attributes']) . '><div>' . $element['#children'] . '</div></form>';
+  return '<form' . attributes($element['#attributes']) . '><div>' . $element['#children'] . '</div></form>';
 }
 
 /**
@@ -3803,12 +3808,12 @@ function theme_textarea($variables) {
 
   // Add resizable behavior.
   if (!empty($element['#resizable'])) {
-    drupal_add_library('system', 'drupal.textarea');
+    add_library('system', 'drupal.textarea');
     $wrapper_attributes['class'][] = 'resizable';
   }
 
-  $output = '<div' . drupal_attributes($wrapper_attributes) . '>';
-  $output .= '<textarea' . drupal_attributes($element['#attributes']) . '>' . check_plain($element['#value']) . '</textarea>';
+  $output = '<div' . attributes($wrapper_attributes) . '>';
+  $output .= '<textarea' . attributes($element['#attributes']) . '>' . check_plain($element['#value']) . '</textarea>';
   $output .= '</div>';
   return $output;
 }
@@ -3830,7 +3835,7 @@ function theme_password($variables) {
   element_set_attributes($element, array('id', 'name', 'size', 'maxlength', 'placeholder'));
   _form_set_class($element, array('form-text'));
 
-  return '<input' . drupal_attributes($element['#attributes']) . ' />';
+  return '<input' . attributes($element['#attributes']) . ' />';
 }
 
 /**
@@ -3840,7 +3845,7 @@ function form_process_weight($element) {
   $element['#is_weight'] = TRUE;
 
   // If the number of options is small enough, use a select field.
-  $max_elements = variable_get('drupal_weight_select_max', DRUPAL_WEIGHT_SELECT_MAX);
+  $max_elements = variable_get('drupal_weight_select_max', WEIGHT_SELECT_MAX);
   if ($element['#delta'] <= $max_elements) {
     $element['#type'] = 'select';
     for ($n = (-1 * $element['#delta']); $n <= $element['#delta']; $n++) {
@@ -3881,7 +3886,7 @@ function theme_file($variables) {
   element_set_attributes($element, array('id', 'name', 'size'));
   _form_set_class($element, array('form-file'));
 
-  return '<input' . drupal_attributes($element['#attributes']) . ' />';
+  return '<input' . attributes($element['#attributes']) . ' />';
 }
 
 /**
@@ -3957,7 +3962,7 @@ function theme_form_element($variables) {
   if (!empty($element['#attributes']['disabled'])) {
     $attributes['class'][] = 'form-disabled';
   }
-  $output = '<div' . drupal_attributes($attributes) . '>' . "\n";
+  $output = '<div' . attributes($attributes) . '>' . "\n";
 
   // If #title is not set, we don't display any label or required marker.
   if (!isset($element['#title'])) {
@@ -4010,7 +4015,7 @@ function theme_form_required_marker($variables) {
     'class' => 'form-required',
     'title' => $t('This field is required.'),
   );
-  return '<abbr' . drupal_attributes($attributes) . '>*</abbr>';
+  return '<abbr' . attributes($attributes) . '>*</abbr>';
 }
 
 /**
@@ -4065,7 +4070,7 @@ function theme_form_element_label($variables) {
   }
 
   // The leading whitespace helps visually separate fields from inline labels.
-  return ' <label' . drupal_attributes($attributes) . '>' . $t('!title !required', array('!title' => $title, '!required' => $required)) . "</label>\n";
+  return ' <label' . attributes($attributes) . '>' . $t('!title !required', array('!title' => $title, '!required' => $required)) . "</label>\n";
 }
 
 /**
@@ -4231,7 +4236,7 @@ function element_validate_number($element, &$form_state) {
  *   else {
  *     $message = t('Finished with an error.');
  *   }
- *   drupal_set_message($message);
+ *   set_message($message);
  *   // Providing data for the redirected page is done through $_SESSION.
  *   foreach ($results as $result) {
  *     $items[] = t('Loaded node %title.', array('%title' => $result));
@@ -4272,7 +4277,7 @@ function element_validate_number($element, &$form_state) {
  *   - 'file': Path to the file containing the definitions of the
  *     'operations' and 'finished' functions, for instance if they don't
  *     reside in the main .module file. The path should be relative to
- *     base_path(), and thus should be built using drupal_get_path().
+ *     base_path(), and thus should be built using get_path().
  *   - 'css': Array of paths to CSS files to be used on the progress page.
  *   - 'url_options': options passed to url() when constructing redirect
  *     URLs for the batch.
@@ -4348,7 +4353,7 @@ function batch_set($batch_definition) {
  * Processes the batch.
  *
  * Unless the batch has been marked with 'progressive' = FALSE, the function
- * issues a drupal_goto and thus ends page execution.
+ * issues a redirect and thus ends page execution.
  *
  * This function is generally not needed in form submit handlers;
  * Form API takes care of batches that were set during form submission.
@@ -4360,14 +4365,14 @@ function batch_set($batch_definition) {
  *   URL of the batch processing page.
  * @param $redirect_callback
  *   (optional) Specify a function to be called to redirect to the progressive
- *   processing page. By default drupal_goto() will be used to redirect to a
+ *   processing page. By default redirect() will be used to redirect to a
  *   page which will do the progressive page. Specifying another function will
  *   allow the progressive processing to be processed differently.
  */
-function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = 'drupal_goto') {
+function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = 'redirect') {
   $batch =& batch_get();
 
-  drupal_theme_initialize();
+  theme_initialize();
 
   if (isset($batch)) {
     // Add process information
@@ -4386,7 +4391,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = 'd
     // The batch is now completely built. Allow other modules to make changes
     // to the batch so that it is easier to reuse batch processes in other
     // environments.
-    drupal_alter('batch', $batch);
+    alter('batch', $batch);
 
     // Assign an arbitrary id: don't rely on a serial column in the 'batch'
     // table, since non-progressive batches skip database storage completely.
@@ -4405,7 +4410,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = 'd
       $t = get_t();
       $batch['error_message'] = $t('Please continue to <a href="@error_url">the error page</a>', array('@error_url' => url($url, array('query' => array('id' => $batch['id'], 'op' => 'finished')))));
 
-      // Clear the way for the drupal_goto() redirection to the batch processing
+      // Clear the way for the redirect() redirection to the batch processing
       // page, by saving and unsetting the 'destination', if there is any.
       if (isset($_GET['destination'])) {
         $batch['destination'] = $_GET['destination'];
@@ -4417,7 +4422,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = 'd
         ->fields(array(
           'bid' => $batch['id'],
           'timestamp' => REQUEST_TIME,
-          'token' => drupal_get_token($batch['id']),
+          'token' => get_token($batch['id']),
           'batch' => serialize($batch),
         ))
         ->execute();
@@ -4426,13 +4431,13 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = 'd
       $_SESSION['batches'][$batch['id']] = TRUE;
 
       // Redirect for processing.
-      $function = $batch['redirect_callback'];
+      $function = 'Drupal\\' . $batch['redirect_callback'];
       $function($batch['url'], array('query' => array('op' => 'start', 'id' => $batch['id'])));
     }
     else {
       // Non-progressive execution: bypass the whole progressbar workflow
       // and execute the batch in one pass.
-      require_once DRUPAL_ROOT . '/core/includes/batch.inc';
+      require_once ROOT . '/core/includes/batch.inc';
       _batch_process();
     }
   }
@@ -4501,13 +4506,13 @@ function _batch_queue($batch_set) {
   // sure the files are manually included.
   if (!isset($queues)) {
     $queues = array();
-    require_once DRUPAL_ROOT . '/core/modules/system/system.queue.inc';
-    require_once DRUPAL_ROOT . '/core/includes/batch.queue.inc';
+    require_once ROOT . '/core/modules/system/system.queue.inc';
+    require_once ROOT . '/core/includes/batch.queue.inc';
   }
 
   if (isset($batch_set['queue'])) {
     $name = $batch_set['queue']['name'];
-    $class = $batch_set['queue']['class'];
+    $class = 'Drupal\\' . $batch_set['queue']['class'];
 
     if (!isset($queues[$class][$name])) {
       $queues[$class][$name] = new $class($name);
diff --git a/core/includes/gettext.inc b/core/includes/gettext.inc
index 9398a5f..6594002 100644
--- a/core/includes/gettext.inc
+++ b/core/includes/gettext.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -33,7 +34,7 @@ function _locale_import_po($file, $langcode, $mode) {
 
   // Check if we have the language already in the database.
   if (!language_load($langcode)) {
-    drupal_set_message(t('The language selected for import is not supported.'), 'error');
+    set_message(t('The language selected for import is not supported.'), 'error');
     return FALSE;
   }
 
@@ -48,7 +49,7 @@ function _locale_import_po($file, $langcode, $mode) {
   list($header_done, $additions, $updates, $deletes, $skips) = _locale_import_one_string('db-report');
 
   if (!$header_done) {
-    drupal_set_message(t('The translation file %filename appears to have a missing or malformed header.', array('%filename' => $file->filename)), 'error');
+    set_message(t('The translation file %filename appears to have a missing or malformed header.', array('%filename' => $file->filename)), 'error');
   }
 
   // Clear cache and force refresh of JavaScript translations.
@@ -58,7 +59,7 @@ function _locale_import_po($file, $langcode, $mode) {
   // Rebuild the menu, strings may have changed.
   menu_rebuild();
 
-  drupal_set_message(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => $additions, '%update' => $updates, '%delete' => $deletes)));
+  set_message(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => $additions, '%update' => $updates, '%delete' => $deletes)));
   watchdog('locale', 'Imported %file into %locale: %number new strings added, %update updated and %delete removed.', array('%file' => $file->filename, '%locale' => $langcode, '%number' => $additions, '%update' => $updates, '%delete' => $deletes));
   if ($skips) {
     if (module_exists('dblog')) {
@@ -67,7 +68,7 @@ function _locale_import_po($file, $langcode, $mode) {
     else {
       $skip_message = format_plural($skips, 'A translation string was skipped because of disallowed or malformed HTML. See the log for details.', '@count translation strings were skipped because of disallowed or malformed HTML. See the log for details.');
     }
-    drupal_set_message($skip_message, 'error');
+    set_message($skip_message, 'error');
     watchdog('locale', '@count disallowed HTML string(s) in %file', array('@count' => $skips, '%file' => $file->uri), WATCHDOG_WARNING);
   }
   return TRUE;
@@ -350,7 +351,7 @@ function _locale_import_message($message, $file, $lineno = NULL) {
     $vars['%line'] = $lineno;
   }
   $t = get_t();
-  drupal_set_message($t($message, $vars), 'error');
+  set_message($t($message, $vars), 'error');
 }
 
 /**
@@ -427,8 +428,8 @@ function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NUL
           for ($i = 3; $i <= count($entries); $i++) {
             $english[] = $english[1];
           }
-          $translation = array_map('_locale_import_append_plural', $value['msgstr'], $entries);
-          $english = array_map('_locale_import_append_plural', $english, $entries);
+          $translation = array_map('Drupal\_locale_import_append_plural', $value['msgstr'], $entries);
+          $english = array_map('Drupal\_locale_import_append_plural', $english, $entries);
           foreach ($translation as $key => $trans) {
             if ($key == 0) {
               $plid = 0;
@@ -621,7 +622,7 @@ function _locale_import_parse_plural_forms($pluralforms, $filepath) {
     return array($nplurals, $plural);
   }
   else {
-    drupal_set_message(t('The translation file %filepath contains an error: the plural formula could not be parsed.', array('%filepath' => $filepath)), 'error');
+    set_message(t('The translation file %filepath contains an error: the plural formula could not be parsed.', array('%filepath' => $filepath)), 'error');
     return FALSE;
   }
 }
diff --git a/core/includes/graph.inc b/core/includes/graph.inc
index 7fcc57a..7666caf 100644
--- a/core/includes/graph.inc
+++ b/core/includes/graph.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -42,9 +43,9 @@
  *   - 'component': Vertices in the same component have the same component
  *     identifier.
  *
- * @see _drupal_depth_first_search()
+ * @see _depth_first_search()
  */
-function drupal_depth_first_search(&$graph) {
+function depth_first_search(&$graph) {
   $state = array(
     // The order of last visit of the depth first search. This is the reverse
     // of the topological order if the graph is acyclic.
@@ -54,7 +55,7 @@ function drupal_depth_first_search(&$graph) {
   );
   // Perform the actual sort.
   foreach ($graph as $start => $data) {
-    _drupal_depth_first_search($graph, $state, $start);
+    _depth_first_search($graph, $state, $start);
   }
 
   // We do such a numbering that every component starts with 0. This is useful
@@ -85,9 +86,9 @@ function drupal_depth_first_search(&$graph) {
  * @param $component
  *   The component of the last vertex.
  *
- * @see drupal_depth_first_search()
+ * @see depth_first_search()
  */
-function _drupal_depth_first_search(&$graph, &$state, $start, &$component = NULL) {
+function _depth_first_search(&$graph, &$state, $start, &$component = NULL) {
   // Assign new component for each new vertex, i.e. when not called recursively.
   if (!isset($component)) {
     $component = $start;
@@ -123,7 +124,7 @@ function _drupal_depth_first_search(&$graph, &$state, $start, &$component = NULL
       // Only visit existing vertices.
       if (isset($graph[$end])) {
         // Visit the connected vertex.
-        _drupal_depth_first_search($graph, $state, $end, $component);
+        _depth_first_search($graph, $state, $end, $component);
 
         // All vertices reachable by $end are also reachable by $start.
         $graph[$start]['paths'] += $graph[$end]['paths'];
diff --git a/core/includes/image.inc b/core/includes/image.inc
index f6ae7f1..4f2c45d 100644
--- a/core/includes/image.inc
+++ b/core/includes/image.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -66,7 +68,7 @@ function image_get_toolkit() {
   if (!isset($toolkit)) {
     $toolkits = image_get_available_toolkits();
     $toolkit = variable_get('image_toolkit', 'gd');
-    if (!isset($toolkits[$toolkit]) || !function_exists('image_' . $toolkit . '_load')) {
+    if (!isset($toolkits[$toolkit]) || !function_exists('Drupal\image_' . $toolkit . '_load')) {
       // The selected toolkit isn't available so return the first one found. If
       // none are available this will return FALSE.
       reset($toolkits);
@@ -91,7 +93,7 @@ function image_get_toolkit() {
  *   Mixed values (typically Boolean indicating successful operation).
  */
 function image_toolkit_invoke($method, stdClass $image, array $params = array()) {
-  $function = 'image_' . $image->toolkit . '_' . $method;
+  $function = 'Drupal\image_' . $image->toolkit . '_' . $method;
   if (function_exists($function)) {
     array_unshift($params, $image);
     return call_user_func_array($function, $params);
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 61f7891..f1c80eb 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, PDO;
 
 /**
  * @file
@@ -94,7 +96,7 @@ function install_drupal($settings = array()) {
   if ($install_state['interactive']) {
     if ($install_state['parameters_changed']) {
       // Redirect to the correct page if the URL parameters have changed.
-      install_goto(install_redirect_url($install_state));
+      install_redirect(install_redirect_url($install_state));
     }
     elseif (isset($output)) {
       // Display a page only if some output is available. Otherwise it is
@@ -119,9 +121,9 @@ function install_drupal($settings = array()) {
  * be used to programmatically submit forms during the installation; the keys
  * of each element indicate the name of the installation task that the form
  * submission is for, and the values are used as the $form_state['values']
- * array that is passed on to the form submission via drupal_form_submit()).
+ * array that is passed on to the form submission via form_submit()).
  *
- * @see drupal_form_submit()
+ * @see form_submit()
  */
 function install_state_defaults() {
   $defaults = array(
@@ -136,7 +138,7 @@ function install_state_defaults() {
     // installation. The keys of each element indicate the name of the
     // installation task that the form submission is for, and the values are
     // used as the $form_state['values'] array that is passed on to the form
-    // submission via drupal_form_submit().
+    // submission via form_submit().
     'forms' => array(),
     // This becomes TRUE only at the end of the installation process, after
     // all available tasks have been completed and Drupal is fully installed.
@@ -167,7 +169,7 @@ function install_state_defaults() {
     // An array of available installation profiles.
     'profiles' => array(),
     // An array of server variables that will be substituted into the global
-    // $_SERVER array via drupal_override_server_variables(). Used by
+    // $_SERVER array via override_server_variables(). Used by
     // non-interactive installations only.
     'server' => array(),
     // This becomes TRUE only when a valid database connection can be
@@ -227,9 +229,9 @@ function install_begin_request(&$install_state) {
   }
 
   // Allow command line scripts to override server variables used by Drupal.
-  require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
+  require_once ROOT . '/core/includes/bootstrap.inc';
   if (!$install_state['interactive']) {
-    drupal_override_server_variables($install_state['server']);
+    override_server_variables($install_state['server']);
   }
 
   // The user agent header is used to pass a database prefix in the request when
@@ -240,32 +242,32 @@ function install_begin_request(&$install_state) {
     exit;
   }
 
-  drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
+  bootstrap(BOOTSTRAP_CONFIGURATION);
 
-  // This must go after drupal_bootstrap(), which unsets globals!
+  // This must go after bootstrap(), which unsets globals!
   global $conf;
 
-  require_once DRUPAL_ROOT . '/core/modules/system/system.install';
-  require_once DRUPAL_ROOT . '/core/includes/common.inc';
-  require_once DRUPAL_ROOT . '/core/includes/file.inc';
-  require_once DRUPAL_ROOT . '/core/includes/install.inc';
-  require_once DRUPAL_ROOT . '/' . variable_get('path_inc', 'core/includes/path.inc');
+  require_once ROOT . '/core/modules/system/system.install';
+  require_once ROOT . '/core/includes/common.inc';
+  require_once ROOT . '/core/includes/file.inc';
+  require_once ROOT . '/core/includes/install.inc';
+  require_once ROOT . '/' . variable_get('path_inc', 'core/includes/path.inc');
 
   // Load module basics (needed for hook invokes).
-  include_once DRUPAL_ROOT . '/core/includes/module.inc';
-  include_once DRUPAL_ROOT . '/core/includes/session.inc';
+  include_once ROOT . '/core/includes/module.inc';
+  include_once ROOT . '/core/includes/session.inc';
 
   // Set up $language, so t() caller functions will still work.
-  drupal_language_initialize();
+  language_initialize();
 
-  require_once DRUPAL_ROOT . '/core/includes/ajax.inc';
+  require_once ROOT . '/core/includes/ajax.inc';
   $module_list['system']['filename'] = 'core/modules/system/system.module';
   $module_list['entity']['filename'] = 'core/modules/entity/entity.module';
   $module_list['user']['filename']   = 'core/modules/user/user.module';
   module_list(TRUE, FALSE, FALSE, $module_list);
-  drupal_load('module', 'system');
-  drupal_load('module', 'entity');
-  drupal_load('module', 'user');
+  load('module', 'system');
+  load('module', 'entity');
+  load('module', 'user');
 
   // Load the cache infrastructure using a "fake" cache implementation that
   // does not attempt to write to the database. We need this during the initial
@@ -276,7 +278,7 @@ function install_begin_request(&$install_state) {
   // continue using the cache implementation they started with) and also
   // because any data put in the cache during the installer is inherently
   // suspect, due to the fact that Drupal is not fully set up yet.
-  require_once DRUPAL_ROOT . '/core/includes/cache.inc';
+  require_once ROOT . '/core/includes/cache.inc';
   $conf['cache_default_class'] = 'Drupal\\Cache\\InstallBackend';
 
   // Prepare for themed output. We need to run this at the beginning of the
@@ -284,7 +286,7 @@ function install_begin_request(&$install_state) {
   // need to run it even in the case of command-line installations, to prevent
   // any code in the installer that happens to initialize the theme system from
   // accessing the database before it is set up yet.)
-  drupal_maintenance_theme();
+  maintenance_theme();
 
   // Check existing settings.php.
   $install_state['settings_verified'] = install_verify_settings();
@@ -292,7 +294,7 @@ function install_begin_request(&$install_state) {
   if ($install_state['settings_verified']) {
     // Initialize the database system. Note that the connection
     // won't be initialized until it is actually requested.
-    require_once DRUPAL_ROOT . '/core/includes/database/database.inc';
+    require_once ROOT . '/core/includes/database/database.inc';
 
     // Verify the last completed task in the database, if there is one.
     $task = install_verify_completed_task();
@@ -382,10 +384,10 @@ function install_run_tasks(&$install_state) {
  *   The output of the task function, if there is any.
  */
 function install_run_task($task, &$install_state) {
-  $function = $task['function'];
+  $function = 'Drupal\\' . $task['function'];
 
   if ($task['type'] == 'form') {
-    require_once DRUPAL_ROOT . '/core/includes/form.inc';
+    require_once ROOT . '/core/includes/form.inc';
     if ($install_state['interactive']) {
       // For interactive forms, build the form and ensure that it will not
       // redirect, since the installer handles its own redirection only after
@@ -397,7 +399,7 @@ function install_run_task($task, &$install_state) {
         'build_info' => array('args' => array(&$install_state)),
         'no_redirect' => TRUE,
       );
-      $form = drupal_build_form($function, $form_state);
+      $form = build_form($task['function'], $form_state);
       // If a successful form submission did not occur, the form needs to be
       // rendered, which means the task is not complete yet.
       if (empty($form_state['executed'])) {
@@ -413,13 +415,13 @@ function install_run_task($task, &$install_state) {
       // values taken from the installation state. Throw an exception if any
       // errors were encountered.
       $form_state = array(
-        'values' => !empty($install_state['forms'][$function]) ? $install_state['forms'][$function] : array(),
+        'values' => !empty($install_state['forms'][$task['function']]) ? $install_state['forms'][$task['function']] : array(),
         // We need to pass $install_state by reference in order for forms to
         // modify it, since the form API will use it in call_user_func_array(),
         // which requires that referenced variables be passed explicitly.
         'build_info' => array('args' => array(&$install_state)),
       );
-      drupal_form_submit($function, $form_state);
+      form_submit($task['function'], $form_state);
       $errors = form_get_errors();
       if (!empty($errors)) {
         throw new Exception(implode("\n", $errors));
@@ -443,7 +445,7 @@ function install_run_task($task, &$install_state) {
       // task is currently running. Otherwise, we need to make sure the batch
       // will complete in one page request.
       if ($install_state['interactive']) {
-        variable_set('install_current_batch', $function);
+        variable_set('install_current_batch', $task['function']);
       }
       else {
         $batch =& batch_get();
@@ -455,8 +457,8 @@ function install_run_task($task, &$install_state) {
     }
     // If we are in the middle of processing this batch, keep sending back
     // any output from the batch process, until the task is complete.
-    elseif ($current_batch == $function) {
-      include_once DRUPAL_ROOT . '/core/includes/batch.inc';
+    elseif ($current_batch == $task['function']) {
+      include_once ROOT . '/core/includes/batch.inc';
       $output = _batch_page();
       // The task is complete when we try to access the batch page and receive
       // FALSE in return, since this means we are at a URL where we are no
@@ -580,11 +582,11 @@ function install_tasks($install_state) {
   if (!empty($install_state['parameters']['profile'])) {
     // Load the profile install file, because it is not always loaded when
     // hook_install_tasks() is invoked (e.g. batch processing).
-    $profile_install_file = DRUPAL_ROOT . '/profiles/' . $install_state['parameters']['profile'] . '/' . $install_state['parameters']['profile'] . '.install';
+    $profile_install_file = ROOT . '/profiles/' . $install_state['parameters']['profile'] . '/' . $install_state['parameters']['profile'] . '.install';
     if (file_exists($profile_install_file)) {
       include_once $profile_install_file;
     }
-    $function = $install_state['parameters']['profile'] . '_install_tasks';
+    $function = 'Drupal\\' . $install_state['parameters']['profile'] . '_install_tasks';
     if (function_exists($function)) {
       $result = $function($install_state);
       if (is_array($result)) {
@@ -608,10 +610,10 @@ function install_tasks($install_state) {
 
   // Allow the installation profile to modify the full list of tasks.
   if (!empty($install_state['parameters']['profile'])) {
-    $profile_file = DRUPAL_ROOT . '/profiles/' . $install_state['parameters']['profile'] . '/' . $install_state['parameters']['profile'] . '.profile';
+    $profile_file = ROOT . '/profiles/' . $install_state['parameters']['profile'] . '/' . $install_state['parameters']['profile'] . '.profile';
     if (file_exists($profile_file)) {
       include_once $profile_file;
-      $function = $install_state['parameters']['profile'] . '_install_tasks_alter';
+      $function = 'Drupal\\' . $install_state['parameters']['profile'] . '_install_tasks_alter';
       if (function_exists($function)) {
         $function($tasks, $install_state);
       }
@@ -659,7 +661,7 @@ function install_tasks_to_display($install_state) {
 /**
  * Returns the URL that should be redirected to during an installation request.
  *
- * The output of this function is suitable for sending to install_goto().
+ * The output of this function is suitable for sending to install_redirect().
  *
  * @param $install_state
  *   An array of information about the current installation state.
@@ -692,7 +694,7 @@ function install_full_redirect_url($install_state) {
 /**
  * Displays themed installer output and ends the page request.
  *
- * Installation tasks should use drupal_set_title() to set the desired page
+ * Installation tasks should use set_title() to set the desired page
  * title, but otherwise this function takes care of theming the overall page
  * output during every step of the installation.
  *
@@ -702,7 +704,7 @@ function install_full_redirect_url($install_state) {
  *   An array of information about the current installation state.
  */
 function install_display_output($output, $install_state) {
-  drupal_page_header();
+  page_header();
   // Only show the task list if there is an active task; otherwise, the page
   // request has ended before tasks have even been started, so there is nothing
   // meaningful to show.
@@ -710,7 +712,7 @@ function install_display_output($output, $install_state) {
     // Let the theming function know when every step of the installation has
     // been completed.
     $active_task = $install_state['installation_finished'] ? NULL : $install_state['active_task'];
-    drupal_add_region_content('sidebar_first', theme('task_list', array('items' => install_tasks_to_display($install_state), 'active' => $active_task)));
+    add_region_content('sidebar_first', theme('task_list', array('items' => install_tasks_to_display($install_state), 'active' => $active_task)));
   }
   print theme('install_page', array('content' => $output));
   exit;
@@ -734,19 +736,19 @@ function install_verify_requirements(&$install_state) {
   $requirements = install_check_requirements($install_state);
 
   // Verify existence of all required modules.
-  $requirements += drupal_verify_profile($install_state);
+  $requirements += verify_profile($install_state);
 
   // Check the severity of the requirements reported.
-  $severity = drupal_requirements_severity($requirements);
+  $severity = requirements_severity($requirements);
 
   // If there are errors, always display them. If there are only warnings, skip
   // them if the user has provided a URL parameter acknowledging the warnings
-  // and indicating a desire to continue anyway. See drupal_requirements_url().
+  // and indicating a desire to continue anyway. See requirements_url().
   if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING && empty($install_state['parameters']['continue']))) {
     if ($install_state['interactive']) {
-      drupal_set_title(st('Requirements problem'));
+      set_title(st('Requirements problem'));
       $status_report = theme('status_report', array('requirements' => $requirements));
-      $status_report .= st('Check the messages and <a href="!url">proceed with the installation</a>.', array('!url' => check_url(drupal_requirements_url($severity))));
+      $status_report .= st('Check the messages and <a href="!url">proceed with the installation</a>.', array('!url' => check_url(requirements_url($severity))));
       return $status_report;
     }
     else {
@@ -775,7 +777,7 @@ function install_verify_requirements(&$install_state) {
  */
 function install_system_module(&$install_state) {
   // Install system.module.
-  drupal_install_system();
+  install_system();
 
   // Enable the user module so that sessions can be recorded during the
   // upcoming bootstrap step.
@@ -787,7 +789,7 @@ function install_system_module(&$install_state) {
 
   // The install profile is also a module, which needs to be installed
   // after all the dependencies have been installed.
-  $modules[] = drupal_get_profile();
+  $modules[] = get_profile();
 
   variable_set('install_profile_modules', array_diff($modules, array('system')));
   $install_state['database_tables_exist'] = TRUE;
@@ -827,7 +829,7 @@ function install_verify_settings() {
   // Verify existing settings (if any).
   if (!empty($databases) && install_verify_pdo()) {
     $database = $databases['default']['default'];
-    drupal_static_reset('conf_path');
+    drupal_static_reset('Drupal\conf_path');
     $settings_file = './' . conf_path(FALSE) . '/settings.php';
     $errors = install_database_errors($database, $settings_file);
     if (empty($errors)) {
@@ -864,14 +866,14 @@ function install_settings_form($form, &$form_state, &$install_state) {
   global $databases;
   $profile = $install_state['parameters']['profile'];
 
-  drupal_static_reset('conf_path');
+  drupal_static_reset('Drupal\conf_path');
   $conf_path = './' . conf_path(FALSE);
   $settings_file = $conf_path . '/settings.php';
   $database = isset($databases['default']['default']) ? $databases['default']['default'] : array();
 
-  drupal_set_title(st('Database configuration'));
+  set_title(st('Database configuration'));
 
-  $drivers = drupal_get_database_types();
+  $drivers = get_database_types();
   $drivers_keys = array_keys($drivers);
 
   $form['driver'] = array(
@@ -879,7 +881,7 @@ function install_settings_form($form, &$form_state, &$install_state) {
     '#title' => st('Database type'),
     '#required' => TRUE,
     '#default_value' => !empty($database['driver']) ? $database['driver'] : current($drivers_keys),
-    '#description' => st('The type of database your @drupal data will be stored in.', array('@drupal' => drupal_install_profile_distribution_name())),
+    '#description' => st('The type of database your @drupal data will be stored in.', array('@drupal' => install_profile_distribution_name())),
   );
   if (count($drivers) == 1) {
     $form['driver']['#disabled'] = TRUE;
@@ -947,10 +949,10 @@ function install_database_errors($database, $settings_file) {
   $errors = array();
 
   // Check database type.
-  $database_types = drupal_get_database_types();
+  $database_types = get_database_types();
   $driver = $database['driver'];
   if (!isset($database_types[$driver])) {
-    $errors['driver'] = st("In your %settings_file file you have configured @drupal to use a %driver server, however your PHP installation currently does not support this database type.", array('%settings_file' => $settings_file, '@drupal' => drupal_install_profile_distribution_name(), '%driver' => $driver));
+    $errors['driver'] = st("In your %settings_file file you have configured @drupal to use a %driver server, however your PHP installation currently does not support this database type.", array('%settings_file' => $settings_file, '@drupal' => install_profile_distribution_name(), '%driver' => $driver));
   }
   else {
     // Run driver specific validation
@@ -987,11 +989,11 @@ function install_settings_form_submit($form, &$form_state) {
     'value'    => array('default' => array('default' => $form_state['storage']['database'])),
     'required' => TRUE,
   );
-  $settings['drupal_hash_salt'] = array(
-    'value'    => drupal_hash_base64(drupal_random_bytes(55)),
+  $settings['hash_salt'] = array(
+    'value'    => hash_base64(random_bytes(55)),
     'required' => TRUE,
   );
-  drupal_rewrite_settings($settings);
+  rewrite_settings($settings);
   // Indicate that the settings file has been verified, and check the database
   // for the last completed task, now that we have a valid connection. This
   // last step is important since we want to trigger an error if the new
@@ -1031,9 +1033,9 @@ function install_select_profile(&$install_state) {
       // yet), rather just a convenience method for setting parameters in the
       // URL.
       if ($install_state['interactive']) {
-        include_once DRUPAL_ROOT . '/core/includes/form.inc';
-        drupal_set_title(st('Select an installation profile'));
-        $form = drupal_get_form('install_select_profile_form', $install_state['profiles']);
+        include_once ROOT . '/core/includes/form.inc';
+        set_title(st('Select an installation profile'));
+        $form = get_form('install_select_profile_form', $install_state['profiles']);
         return drupal_render($form);
       }
       else {
@@ -1058,7 +1060,7 @@ function _install_select_profile($profiles) {
   if (sizeof($profiles) == 1) {
     $profile = array_pop($profiles);
     // TODO: is this right?
-    require_once DRUPAL_ROOT . '/' . $profile->uri;
+    require_once ROOT . '/' . $profile->uri;
     return $profile->name;
   }
   else {
@@ -1084,7 +1086,7 @@ function install_select_profile_form($form, &$form_state, $profile_files) {
 
   foreach ($profile_files as $profile) {
     // TODO: is this right?
-    include_once DRUPAL_ROOT . '/' . $profile->uri;
+    include_once ROOT . '/' . $profile->uri;
 
     $details = install_profile_info($profile->name);
     // Don't show hidden profiles. This is used by to hide the testing profile,
@@ -1214,7 +1216,7 @@ function install_select_language(&$install_state) {
       if ($install_state['interactive']) {
         $directory = variable_get('locale_translate_file_directory', conf_path() . '/files/translations');
 
-        drupal_set_title(st('Choose language'));
+        set_title(st('Choose language'));
         if (!empty($install_state['parameters']['translate'])) {
           $output = '<p>Follow these steps to translate Drupal into your language:</p>';
           $output .= '<ol>';
@@ -1224,13 +1226,13 @@ function install_select_language(&$install_state) {
           $output .= '<p>For more information on installing Drupal in different languages, visit the <a href="http://drupal.org/localize" target="_blank">drupal.org handbook page</a>.</p>';
           $output .= '<p>How should the installation continue?</p>';
           $output .= '<ul>';
-          $output .= '<li><a href="' . check_url(drupal_current_script_url(array('translate' => NULL))) . '">Reload the language selection page after adding translations</a></li>';
-          $output .= '<li><a href="' . check_url(drupal_current_script_url(array('langcode' => 'en', 'translate' => NULL))) . '">Continue installation in English</a></li>';
+          $output .= '<li><a href="' . check_url(current_script_url(array('translate' => NULL))) . '">Reload the language selection page after adding translations</a></li>';
+          $output .= '<li><a href="' . check_url(current_script_url(array('langcode' => 'en', 'translate' => NULL))) . '">Continue installation in English</a></li>';
           $output .= '</ul>';
         }
         else {
-          include_once DRUPAL_ROOT . '/core/includes/form.inc';
-          $elements = drupal_get_form('install_select_language_form', $files);
+          include_once ROOT . '/core/includes/form.inc';
+          $elements = get_form('install_select_language_form', $files);
           $output = drupal_render($elements);
         }
         return $output;
@@ -1248,9 +1250,9 @@ function install_select_language(&$install_state) {
       // yet), rather just a convenience method for setting parameters in the
       // URL.
       if ($install_state['interactive']) {
-        drupal_set_title(st('Choose language'));
-        include_once DRUPAL_ROOT . '/core/includes/form.inc';
-        $elements = drupal_get_form('install_select_language_form', $files);
+        set_title(st('Choose language'));
+        include_once ROOT . '/core/includes/form.inc';
+        $elements = get_form('install_select_language_form', $files);
         return drupal_render($elements);
       }
       else {
@@ -1264,8 +1266,8 @@ function install_select_language(&$install_state) {
  * Form API array definition for language selection.
  */
 function install_select_language_form($form, &$form_state, $files) {
-  include_once DRUPAL_ROOT . '/core/includes/standard.inc';
-  include_once DRUPAL_ROOT . '/core/includes/locale.inc';
+  include_once ROOT . '/core/includes/standard.inc';
+  include_once ROOT . '/core/includes/locale.inc';
 
   $standard_languages = standard_language_list();
   $select_options = array();
@@ -1297,7 +1299,7 @@ function install_select_language_form($form, &$form_state, $files) {
 
   if (count($files) == 1) {
     $form['help'] = array(
-      '#markup' => '<p><a href="' . check_url(drupal_current_script_url(array('translate' => 'true'))) . '">' . st('Learn how to install Drupal in other languages') . '</a></p>',
+      '#markup' => '<p><a href="' . check_url(current_script_url(array('translate' => 'true'))) . '">' . st('Learn how to install Drupal in other languages') . '</a></p>',
     );
   }
   $form['actions'] = array('#type' => 'actions');
@@ -1312,7 +1314,7 @@ function install_select_language_form($form, &$form_state, $files) {
  * Indicates that there are no profiles available.
  */
 function install_no_profile_error() {
-  drupal_set_title(st('No profiles available'));
+  set_title(st('No profiles available'));
   return st('We were unable to find any installation profiles. Installation profiles tell us what modules to enable and what schema to install in the database. A profile is necessary to continue with the installation process.');
 }
 
@@ -1322,7 +1324,7 @@ function install_no_profile_error() {
 function install_already_done_error() {
   global $base_url;
 
-  drupal_set_title(st('Drupal already installed'));
+  set_title(st('Drupal already installed'));
   return st('<ul><li>To start over, you must empty your existing database.</li><li>To install to a different database, edit the appropriate <em>settings.php</em> file in the <em>sites</em> folder.</li><li>To upgrade an existing installation, proceed to the <a href="@base-url/core/update.php">update script</a>.</li><li>View your <a href="@base-url">existing site</a>.</li></ul>', array('@base-url' => $base_url));
 }
 
@@ -1335,7 +1337,7 @@ function install_already_done_error() {
  *   the profile cannot be loaded.
  */
 function install_load_profile(&$install_state) {
-  $profile_file = DRUPAL_ROOT . '/profiles/' . $install_state['parameters']['profile'] . '/' . $install_state['parameters']['profile'] . '.profile';
+  $profile_file = ROOT . '/profiles/' . $install_state['parameters']['profile'] . '/' . $install_state['parameters']['profile'] . '.profile';
   if (file_exists($profile_file)) {
     include_once $profile_file;
     $install_state['profile_info'] = install_profile_info($install_state['parameters']['profile'], $install_state['parameters']['langcode']);
@@ -1352,7 +1354,7 @@ function install_load_profile(&$install_state) {
  *   An array of information about the current installation state.
  */
 function install_bootstrap_full(&$install_state) {
-  drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+  bootstrap(BOOTSTRAP_FULL);
 }
 
 /**
@@ -1401,7 +1403,7 @@ function install_profile_modules(&$install_state) {
   }
   $batch = array(
     'operations' => $operations,
-    'title' => st('Installing @drupal', array('@drupal' => drupal_install_profile_distribution_name())),
+    'title' => st('Installing @drupal', array('@drupal' => install_profile_distribution_name())),
     'error_message' => st('The installation has encountered an error.'),
     'finished' => '_install_profile_modules_finished',
   );
@@ -1418,11 +1420,11 @@ function install_profile_modules(&$install_state) {
  *   The batch definition, if there are language files to import.
  */
 function install_import_translations(&$install_state) {
-  include_once DRUPAL_ROOT . '/core/includes/locale.inc';
-  include_once drupal_get_path('module', 'locale') . '/locale.bulk.inc';
+  include_once ROOT . '/core/includes/locale.inc';
+  include_once get_path('module', 'locale') . '/locale.bulk.inc';
   $langcode = $install_state['parameters']['langcode'];
 
-  include_once DRUPAL_ROOT . '/core/includes/standard.inc';
+  include_once ROOT . '/core/includes/standard.inc';
   $standard_languages = standard_language_list();
   if (!isset($standard_languages[$langcode])) {
     // Drupal does not know about this language, so we prefill its values with
@@ -1462,7 +1464,7 @@ function install_import_translations(&$install_state) {
  *   The form API definition for the site configuration form.
  */
 function install_configure_form($form, &$form_state, &$install_state) {
-  drupal_set_title(st('Configure site'));
+  set_title(st('Configure site'));
 
   // Warn about settings.php permissions risk
   $settings_dir = conf_path();
@@ -1474,31 +1476,31 @@ function install_configure_form($form, &$form_state, &$install_state) {
   // especially out of place on the last page of the installer, where it would
   // distract from the message that the Drupal installation has completed
   // successfully.)
-  if (empty($_POST) && (!drupal_verify_install_file(DRUPAL_ROOT . '/' . $settings_file, FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE) || !drupal_verify_install_file(DRUPAL_ROOT . '/' . $settings_dir, FILE_NOT_WRITABLE, 'dir'))) {
-    drupal_set_message(st('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the <a href="@handbook_url">online handbook</a>.', array('%dir' => $settings_dir, '%file' => $settings_file, '@handbook_url' => 'http://drupal.org/server-permissions')), 'warning');
+  if (empty($_POST) && (!verify_install_file(ROOT . '/' . $settings_file, FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE) || !verify_install_file(ROOT . '/' . $settings_dir, FILE_NOT_WRITABLE, 'dir'))) {
+    set_message(st('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the <a href="@handbook_url">online handbook</a>.', array('%dir' => $settings_dir, '%file' => $settings_file, '@handbook_url' => 'http://drupal.org/server-permissions')), 'warning');
   }
 
-  drupal_add_js(drupal_get_path('module', 'system') . '/system.js');
+  add_js(get_path('module', 'system') . '/system.js');
   // Add JavaScript time zone detection.
-  drupal_add_js('core/misc/timezone.js');
+  add_js('core/misc/timezone.js');
   // We add these strings as settings because JavaScript translation does not
   // work on install time.
-  drupal_add_js(array('copyFieldValue' => array('edit-site-mail' => array('edit-account-mail'))), 'setting');
-  drupal_add_js('jQuery(function () { Drupal.cleanURLsInstallCheck(); });', 'inline');
+  add_js(array('copyFieldValue' => array('edit-site-mail' => array('edit-account-mail'))), 'setting');
+  add_js('jQuery(function () { Drupal.cleanURLsInstallCheck(); });', 'inline');
   // Add JS to show / hide the 'Email administrator about site updates' elements
-  drupal_add_js('jQuery(function () { Drupal.hideEmailAdministratorCheckbox() });', 'inline');
+  add_js('jQuery(function () { Drupal.hideEmailAdministratorCheckbox() });', 'inline');
   // Build menu to allow clean URL check.
   menu_rebuild();
 
   // Cache a fully-built schema. This is necessary for any invocation of
   // index.php because: (1) setting cache table entries requires schema
   // information, (2) that occurs during bootstrap before any module are
-  // loaded, so (3) if there is no cached schema, drupal_get_schema() will
+  // loaded, so (3) if there is no cached schema, get_schema() will
   // try to generate one but with no loaded modules will return nothing.
   //
   // This logically could be done during the 'install_finished' task, but the
   // clean URL check requires it now.
-  drupal_get_schema(NULL, TRUE);
+  get_schema(NULL, TRUE);
 
   // Return the form.
   return _install_configure_form($form, $form_state, $install_state);
@@ -1519,7 +1521,7 @@ function install_configure_form($form, &$form_state, &$install_state) {
  *   http://drupal.org/node/1191488.
  */
 function install_import_translations_remaining(&$install_state) {
-  include_once drupal_get_path('module', 'locale') . '/locale.bulk.inc';
+  include_once get_path('module', 'locale') . '/locale.bulk.inc';
   return locale_translate_batch_import_files($install_state['parameters']['langcode']);
 }
 
@@ -1533,33 +1535,33 @@ function install_import_translations_remaining(&$install_state) {
  *   A message informing the user that the installation is complete.
  */
 function install_finished(&$install_state) {
-  drupal_set_title(st('@drupal installation complete', array('@drupal' => drupal_install_profile_distribution_name())), PASS_THROUGH);
-  $messages = drupal_set_message();
-  $output = '<p>' . st('Congratulations, you installed @drupal!', array('@drupal' => drupal_install_profile_distribution_name())) . '</p>';
+  set_title(st('@drupal installation complete', array('@drupal' => install_profile_distribution_name())), PASS_THROUGH);
+  $messages = set_message();
+  $output = '<p>' . st('Congratulations, you installed @drupal!', array('@drupal' => install_profile_distribution_name())) . '</p>';
   $output .= '<p>' . (isset($messages['error']) ? st('Review the messages above before visiting <a href="@url">your new site</a>.', array('@url' => url(''))) : st('<a href="@url">Visit your new site</a>.', array('@url' => url('')))) . '</p>';
 
   // Flush all caches to ensure that any full bootstraps during the installer
   // do not leave stale cached data, and that any content types or other items
   // registered by the install profile are registered correctly.
-  drupal_flush_all_caches();
+  flush_all_caches();
 
   // Remember the profile which was used.
-  variable_set('install_profile', drupal_get_profile());
+  variable_set('install_profile', get_profile());
 
   // Install profiles are always loaded last
   db_update('system')
     ->fields(array('weight' => 1000))
     ->condition('type', 'module')
-    ->condition('name', drupal_get_profile())
+    ->condition('name', get_profile())
     ->execute();
 
   // Cache a fully-built schema.
-  drupal_get_schema(NULL, TRUE);
+  get_schema(NULL, TRUE);
 
   // Run cron to populate update status tables (if available) so that users
   // will be warned if they've installed an out of date Drupal version.
   // Will also trigger indexing of profile-supplied content or feeds.
-  drupal_cron_run();
+  cron_run();
 
   return $output;
 }
@@ -1569,7 +1571,7 @@ function install_finished(&$install_state) {
  */
 function _install_module_batch($module, $module_name, &$context) {
   // Install and enable the module right away, so that the module will be
-  // loaded by drupal_bootstrap in subsequent batch requests, and other
+  // loaded by bootstrap in subsequent batch requests, and other
   // modules possibly depending on it can safely perform their installation
   // steps.
   module_enable(array($module), FALSE);
@@ -1583,7 +1585,7 @@ function _install_module_batch($module, $module_name, &$context) {
 function _install_profile_modules_finished($success, $results, $operations) {
   // Flush all caches to complete the module installation process. Subsequent
   // installation tasks will now have full access to the profile's modules.
-  drupal_flush_all_caches();
+  flush_all_caches();
 }
 
 /**
@@ -1593,7 +1595,7 @@ function install_check_requirements($install_state) {
   $profile = $install_state['parameters']['profile'];
 
   // Check the profile requirements.
-  $requirements = drupal_check_profile($profile);
+  $requirements = check_profile($profile);
 
   // If Drupal is not set up already, we need to create a settings file.
   if (!$install_state['settings_verified']) {
@@ -1604,30 +1606,30 @@ function install_check_requirements($install_state) {
     $file = $conf_path;
     $exists = FALSE;
     // Verify that the directory exists.
-    if (drupal_verify_install_file($conf_path, FILE_EXIST, 'dir')) {
+    if (verify_install_file($conf_path, FILE_EXIST, 'dir')) {
       // Check if a settings.php file already exists.
       $file = $settings_file;
-      if (drupal_verify_install_file($settings_file, FILE_EXIST)) {
+      if (verify_install_file($settings_file, FILE_EXIST)) {
         // If it does, make sure it is writable.
-        $writable = drupal_verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE);
+        $writable = verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE);
         $exists = TRUE;
       }
     }
 
     // If default.settings.php does not exist, or is not readable, throw an
     // error.
-    if (!drupal_verify_install_file($default_settings_file, FILE_EXIST|FILE_READABLE)) {
+    if (!verify_install_file($default_settings_file, FILE_EXIST|FILE_READABLE)) {
       $requirements['default settings file exists'] = array(
         'title'       => st('Default settings file'),
         'value'       => st('The default settings file does not exist.'),
         'severity'    => REQUIREMENT_ERROR,
-        'description' => st('The @drupal installer requires that the %default-file file not be modified in any way from the original download.', array('@drupal' => drupal_install_profile_distribution_name(), '%default-file' => $default_settings_file)),
+        'description' => st('The @drupal installer requires that the %default-file file not be modified in any way from the original download.', array('@drupal' => install_profile_distribution_name(), '%default-file' => $default_settings_file)),
       );
     }
     // Otherwise, if settings.php does not exist yet, we can try to copy
     // default.settings.php to create it.
     elseif (!$exists) {
-      $copied = drupal_verify_install_file($conf_path, FILE_EXIST|FILE_WRITABLE, 'dir') && @copy($default_settings_file, $settings_file);
+      $copied = verify_install_file($conf_path, FILE_EXIST|FILE_WRITABLE, 'dir') && @copy($default_settings_file, $settings_file);
       if ($copied) {
         // If the new settings file has the same owner as default.settings.php,
         // this means default.settings.php is owned by the webserver user.
@@ -1638,7 +1640,7 @@ function install_check_requirements($install_state) {
         // having settings.php also owned by the webserver does not introduce
         // any additional security risk, so we keep the file in place.
         if (fileowner($default_settings_file) === fileowner($settings_file)) {
-          $writable = drupal_verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE);
+          $writable = verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE);
           $exists = TRUE;
         }
         // If settings.php and default.settings.php have different owners, this
@@ -1662,7 +1664,7 @@ function install_check_requirements($install_state) {
           $exists = !$deleted;
           if ($exists) {
             $settings_file_ownership_error = TRUE;
-            $writable = drupal_verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE);
+            $writable = verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE);
           }
         }
       }
@@ -1674,7 +1676,7 @@ function install_check_requirements($install_state) {
         'title'       => st('Settings file'),
         'value'       => st('The settings file does not exist.'),
         'severity'    => REQUIREMENT_ERROR,
-        'description' => st('The @drupal installer requires that you create a settings file as part of the installation process. Copy the %default_file file to %file. More details about installing Drupal are available in <a href="@install_txt">INSTALL.txt</a>.', array('@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, '%default_file' => $default_settings_file, '@install_txt' => base_path() . 'core/INSTALL.txt')),
+        'description' => st('The @drupal installer requires that you create a settings file as part of the installation process. Copy the %default_file file to %file. More details about installing Drupal are available in <a href="@install_txt">INSTALL.txt</a>.', array('@drupal' => install_profile_distribution_name(), '%file' => $file, '%default_file' => $default_settings_file, '@install_txt' => base_path() . 'core/INSTALL.txt')),
       );
     }
     else {
@@ -1688,7 +1690,7 @@ function install_check_requirements($install_state) {
           'title'       => st('Settings file'),
           'value'       => st('The settings file is not writable.'),
           'severity'    => REQUIREMENT_ERROR,
-          'description' => st('The @drupal installer requires write permissions to %file during the installation process. If you are unsure how to grant file permissions, consult the <a href="@handbook_url">online handbook</a>.', array('@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, '@handbook_url' => 'http://drupal.org/server-permissions')),
+          'description' => st('The @drupal installer requires write permissions to %file during the installation process. If you are unsure how to grant file permissions, consult the <a href="@handbook_url">online handbook</a>.', array('@drupal' => install_profile_distribution_name(), '%file' => $file, '@handbook_url' => 'http://drupal.org/server-permissions')),
         );
       }
       else {
@@ -1702,7 +1704,7 @@ function install_check_requirements($install_state) {
           'title'       => st('Settings file'),
           'value'       => st('The settings file is owned by the web server.'),
           'severity'    => REQUIREMENT_ERROR,
-          'description' => st('The @drupal installer failed to create a settings file with proper file ownership. Log on to your web server, remove the existing %file file, and create a new one by copying the %default_file file to %file. More details about installing Drupal are available in <a href="@install_txt">INSTALL.txt</a>. If you have problems with the file permissions on your server, consult the <a href="@handbook_url">online handbook</a>.', array('@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, '%default_file' => $default_settings_file, '@install_txt' => base_path() . 'core/INSTALL.txt', '@handbook_url' => 'http://drupal.org/server-permissions')),
+          'description' => st('The @drupal installer failed to create a settings file with proper file ownership. Log on to your web server, remove the existing %file file, and create a new one by copying the %default_file file to %file. More details about installing Drupal are available in <a href="@install_txt">INSTALL.txt</a>. If you have problems with the file permissions on your server, consult the <a href="@handbook_url">online handbook</a>.', array('@drupal' => install_profile_distribution_name(), '%file' => $file, '%default_file' => $default_settings_file, '@install_txt' => base_path() . 'core/INSTALL.txt', '@handbook_url' => 'http://drupal.org/server-permissions')),
         );
       }
     }
@@ -1714,7 +1716,7 @@ function install_check_requirements($install_state) {
  * Forms API array definition for site configuration.
  */
 function _install_configure_form($form, &$form_state, &$install_state) {
-  include_once DRUPAL_ROOT . '/core/includes/locale.inc';
+  include_once ROOT . '/core/includes/locale.inc';
 
   $form['site_information'] = array(
     '#type' => 'fieldset',
diff --git a/core/includes/install.inc b/core/includes/install.inc
index 533678f..d017b79 100644
--- a/core/includes/install.inc
+++ b/core/includes/install.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, PDO;
 
 /**
  * Indicates that a module has not been installed yet.
@@ -73,8 +75,8 @@ const FILE_NOT_EXECUTABLE = 128;
 /**
  * Initialize the update system by loading all installed module's .install files.
  */
-function drupal_load_updates() {
-  foreach (drupal_get_installed_schema_version(NULL, FALSE, TRUE) as $module => $schema_version) {
+function load_updates() {
+  foreach (get_installed_schema_version(NULL, FALSE, TRUE) as $module => $schema_version) {
     if ($schema_version > -1) {
       module_load_install($module);
     }
@@ -90,7 +92,7 @@ function drupal_load_updates() {
  *   If the module has updates, an array of available updates sorted by version.
  *   Otherwise, FALSE.
  */
-function drupal_get_schema_versions($module) {
+function get_schema_versions($module) {
   $updates = &drupal_static(__FUNCTION__, NULL);
   if (!isset($updates[$module])) {
     $updates = array();
@@ -100,7 +102,8 @@ function drupal_get_schema_versions($module) {
     }
 
     // Prepare regular expression to match all possible defined hook_update_N().
-    $regexp = '/^(?P<module>.+)_update_(?P<version>\d+)$/';
+    // Namespaces from get_defined_functions() are lowercase.
+    $regexp = '/^drupal\\\\(?P<module>.+)_update_(?P<version>\d+)$/';
     $functions = get_defined_functions();
     // Narrow this down to functions ending with an integer, since all
     // hook_update_N() functions end this way, and there are other
@@ -138,7 +141,7 @@ function drupal_get_schema_versions($module) {
  *   The currently installed schema version, or SCHEMA_UNINSTALLED if the
  *   module is not installed.
  */
-function drupal_get_installed_schema_version($module, $reset = FALSE, $array = FALSE) {
+function get_installed_schema_version($module, $reset = FALSE, $array = FALSE) {
   static $versions = array();
 
   if ($reset) {
@@ -169,14 +172,14 @@ function drupal_get_installed_schema_version($module, $reset = FALSE, $array = F
  * @param $version
  *   The new schema version.
  */
-function drupal_set_installed_schema_version($module, $version) {
+function set_installed_schema_version($module, $version) {
   db_update('system')
     ->fields(array('schema_version' => $version))
     ->condition('name', $module)
     ->execute();
 
   // Reset the static cache of module schema versions.
-  drupal_get_installed_schema_version(NULL, TRUE);
+  get_installed_schema_version(NULL, TRUE);
 }
 
 /**
@@ -188,16 +191,16 @@ function drupal_set_installed_schema_version($module, $version) {
  *
  * @see install_profile_info()
  */
-function drupal_install_profile_distribution_name() {
+function install_profile_distribution_name() {
   // During installation, the profile information is stored in the global
   // installation state (it might not be saved anywhere yet).
-  if (drupal_installation_attempted()) {
+  if (installation_attempted()) {
     global $install_state;
     return $install_state['profile_info']['distribution_name'];
   }
   // At all other times, we load the profile via standard methods.
   else {
-    $profile = drupal_get_profile();
+    $profile = get_profile();
     $info = system_get_info('module', $profile);
     return $info['distribution_name'];
   }
@@ -212,7 +215,7 @@ function drupal_install_profile_distribution_name() {
  * @return
  *   The auto-detected $base_url that should be configured in settings.php
  */
-function drupal_detect_baseurl($file = 'core/install.php') {
+function detect_baseurl($file = 'core/install.php') {
   $proto = $_SERVER['HTTPS'] ? 'https://' : 'http://';
   $host = $_SERVER['SERVER_NAME'];
   $port = ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']);
@@ -228,8 +231,8 @@ function drupal_detect_baseurl($file = 'core/install.php') {
  * @return
  *  An array of database types compiled into PHP.
  */
-function drupal_detect_database_types() {
-  $databases = drupal_get_database_types();
+function detect_database_types() {
+  $databases = get_database_types();
 
   foreach ($databases as $driver => $installer) {
     $databases[$driver] = $installer->name();
@@ -244,7 +247,7 @@ function drupal_detect_database_types() {
  * @return
  *  An array of database installer objects compiled into PHP.
  */
-function drupal_get_database_types() {
+function get_database_types() {
   $databases = array();
 
   // We define a driver as a directory in /core/includes/database that in turn
@@ -252,8 +255,8 @@ function drupal_get_database_types() {
   // without modifying the installer.
   // Because we have no registry yet, we need to also include the install.inc
   // file for the driver explicitly.
-  require_once DRUPAL_ROOT . '/core/includes/database/database.inc';
-  foreach (file_scan_directory(DRUPAL_ROOT . '/core/includes/database', '/^[a-z]*$/i', array('recurse' => FALSE)) as $file) {
+  require_once ROOT . '/core/includes/database/database.inc';
+  foreach (file_scan_directory(ROOT . '/core/includes/database', '/^[a-z]*$/i', array('recurse' => FALSE)) as $file) {
     if (file_exists($file->uri . '/database.inc') && file_exists($file->uri . '/install.inc')) {
       $drivers[$file->filename] = $file->uri;
     }
@@ -476,7 +479,7 @@ abstract class DatabaseTasks {
       '#default_value' => empty($database['database']) ? '' : $database['database'],
       '#size' => 45,
       '#required' => TRUE,
-      '#description' => st('The name of the database your @drupal data will be stored in. It must exist on your server before @drupal can be installed.', array('@drupal' => drupal_install_profile_distribution_name())),
+      '#description' => st('The name of the database your @drupal data will be stored in. It must exist on your server before @drupal can be installed.', array('@drupal' => install_profile_distribution_name())),
     );
 
     $form['username'] = array(
@@ -504,14 +507,14 @@ abstract class DatabaseTasks {
       '#weight' => 10,
     );
 
-    $profile = drupal_get_profile();
+    $profile = get_profile();
     $db_prefix = ($profile == 'standard') ? 'drupal_' : $profile . '_';
     $form['advanced_options']['db_prefix'] = array(
       '#type' => 'textfield',
       '#title' => st('Table prefix'),
       '#default_value' => '',
       '#size' => 45,
-      '#description' => st('If more than one application will be sharing this database, enter a table prefix such as %prefix for your @drupal site here.', array('@drupal' => drupal_install_profile_distribution_name(), '%prefix' => $db_prefix)),
+      '#description' => st('If more than one application will be sharing this database, enter a table prefix such as %prefix for your @drupal site here.', array('@drupal' => install_profile_distribution_name(), '%prefix' => $db_prefix)),
       '#weight' => 10,
     );
 
@@ -581,9 +584,9 @@ class DatabaseTaskException extends Exception {
  * @param $settings
  *   An array of settings that need to be updated.
  */
-function drupal_rewrite_settings($settings = array()) {
+function rewrite_settings($settings = array()) {
   $default_settings = 'sites/default/default.settings.php';
-  drupal_static_reset('conf_path');
+  drupal_static_reset('Drupal\conf_path');
   $settings_file = conf_path(FALSE) . '/settings.php';
 
   // Build list of setting names and insert the values into the global namespace.
@@ -595,7 +598,7 @@ function drupal_rewrite_settings($settings = array()) {
 
   $buffer = NULL;
   $first = TRUE;
-  if ($fp = fopen(DRUPAL_ROOT . '/' . $default_settings, 'r')) {
+  if ($fp = fopen(ROOT . '/' . $default_settings, 'r')) {
     // Step line by line through settings.php.
     while (!feof($fp)) {
       $line = fgets($fp);
@@ -643,7 +646,7 @@ function drupal_rewrite_settings($settings = array()) {
       }
     }
 
-    $fp = fopen(DRUPAL_ROOT . '/' . $settings_file, 'w');
+    $fp = fopen(ROOT . '/' . $settings_file, 'w');
     if ($fp && fwrite($fp, $buffer) === FALSE) {
       throw new Exception(st('Failed to modify %settings. Verify the file permissions.', array('%settings' => $settings_file)));
     }
@@ -661,13 +664,13 @@ function drupal_rewrite_settings($settings = array()) {
  * @return
  *   The list of modules to install.
  */
-function drupal_verify_profile($install_state) {
+function verify_profile($install_state) {
   $profile = $install_state['parameters']['profile'];
 
-  include_once DRUPAL_ROOT . '/core/includes/file.inc';
-  include_once DRUPAL_ROOT . '/core/includes/common.inc';
+  include_once ROOT . '/core/includes/file.inc';
+  include_once ROOT . '/core/includes/common.inc';
 
-  $profile_file = DRUPAL_ROOT . "/profiles/$profile/$profile.profile";
+  $profile_file = ROOT . "/profiles/$profile/$profile.profile";
 
   if (!isset($profile) || !file_exists($profile_file)) {
     throw new Exception(install_no_profile_error());
@@ -676,13 +679,13 @@ function drupal_verify_profile($install_state) {
 
   // Get a list of modules that exist in Drupal's assorted subdirectories.
   $present_modules = array();
-  foreach (drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.module$/', 'modules', 'name', 0) as $present_module) {
+  foreach (system_listing('/^' . PHP_FUNCTION_PATTERN . '\.module$/', 'modules', 'name', 0) as $present_module) {
     $present_modules[] = $present_module->name;
   }
 
   // The install profile is also a module, which needs to be installed after all the other dependencies
   // have been installed.
-  $present_modules[] = drupal_get_profile();
+  $present_modules[] = get_profile();
 
   // Verify that all of the profile's required modules are present.
   $missing_modules = array_diff($info['dependencies'], $present_modules);
@@ -710,12 +713,12 @@ function drupal_verify_profile($install_state) {
  * Separated from the installation of other modules so core system
  * functions can be made available while other modules are installed.
  */
-function drupal_install_system() {
-  $system_path = drupal_get_path('module', 'system');
-  require_once DRUPAL_ROOT . '/' . $system_path . '/system.install';
+function install_system() {
+  $system_path = get_path('module', 'system');
+  require_once ROOT . '/' . $system_path . '/system.install';
   module_invoke('system', 'install');
 
-  $system_versions = drupal_get_schema_versions('system');
+  $system_versions = get_schema_versions('system');
   $system_version = $system_versions ? max($system_versions) : SCHEMA_INSTALLED;
   db_insert('system')
     ->fields(array('filename', 'name', 'type', 'owner', 'status', 'schema_version', 'bootstrap'))
@@ -748,16 +751,16 @@ function drupal_install_system() {
  *   FALSE if one or more dependent modules are missing from the list, TRUE
  *   otherwise.
  */
-function drupal_uninstall_modules($module_list = array(), $uninstall_dependents = TRUE) {
+function uninstall_modules($module_list = array(), $uninstall_dependents = TRUE) {
   if ($uninstall_dependents) {
     // Get all module data so we can find dependents and sort.
     $module_data = system_rebuild_module_data();
     // Create an associative array with weights as values.
     $module_list = array_flip(array_values($module_list));
 
-    $profile = drupal_get_profile();
+    $profile = get_profile();
     while (list($module) = each($module_list)) {
-      if (!isset($module_data[$module]) || drupal_get_installed_schema_version($module) == SCHEMA_UNINSTALLED) {
+      if (!isset($module_data[$module]) || get_installed_schema_version($module) == SCHEMA_UNINSTALLED) {
         // This module doesn't exist or is already uninstalled, skip it.
         unset($module_list[$module]);
         continue;
@@ -769,7 +772,7 @@ function drupal_uninstall_modules($module_list = array(), $uninstall_dependents
       // them automatically because uninstalling a module is a destructive
       // operation.
       foreach (array_keys($module_data[$module]->required_by) as $dependent) {
-        if (!isset($module_list[$dependent]) && drupal_get_installed_schema_version($dependent) != SCHEMA_UNINSTALLED && $dependent != $profile) {
+        if (!isset($module_list[$dependent]) && get_installed_schema_version($dependent) != SCHEMA_UNINSTALLED && $dependent != $profile) {
           return FALSE;
         }
       }
@@ -784,10 +787,10 @@ function drupal_uninstall_modules($module_list = array(), $uninstall_dependents
     // Uninstall the module.
     module_load_install($module);
     module_invoke($module, 'uninstall');
-    drupal_uninstall_schema($module);
+    uninstall_schema($module);
 
     watchdog('system', '%module module uninstalled.', array('%module' => $module), WATCHDOG_INFO);
-    drupal_set_installed_schema_version($module, SCHEMA_UNINSTALLED);
+    set_installed_schema_version($module, SCHEMA_UNINSTALLED);
   }
 
   if (!empty($module_list)) {
@@ -810,7 +813,7 @@ function drupal_uninstall_modules($module_list = array(), $uninstall_dependents
  * @return
  *   TRUE on success or FALSE on failure. A message is set for the latter.
  */
-function drupal_verify_install_file($file, $mask = NULL, $type = 'file') {
+function verify_install_file($file, $mask = NULL, $type = 'file') {
   $return = TRUE;
   // Check for files that shouldn't be there.
   if (isset($mask) && ($mask & FILE_NOT_EXIST) && file_exists($file)) {
@@ -833,7 +836,7 @@ function drupal_verify_install_file($file, $mask = NULL, $type = 'file') {
           case FILE_EXIST:
             if (!file_exists($file)) {
               if ($type == 'dir') {
-                drupal_install_mkdir($file, $mask);
+                install_mkdir($file, $mask);
               }
               if (!file_exists($file)) {
                 $return = FALSE;
@@ -841,32 +844,32 @@ function drupal_verify_install_file($file, $mask = NULL, $type = 'file') {
             }
             break;
           case FILE_READABLE:
-            if (!is_readable($file) && !drupal_install_fix_file($file, $mask)) {
+            if (!is_readable($file) && !install_fix_file($file, $mask)) {
               $return = FALSE;
             }
             break;
           case FILE_WRITABLE:
-            if (!is_writable($file) && !drupal_install_fix_file($file, $mask)) {
+            if (!is_writable($file) && !install_fix_file($file, $mask)) {
               $return = FALSE;
             }
             break;
           case FILE_EXECUTABLE:
-            if (!is_executable($file) && !drupal_install_fix_file($file, $mask)) {
+            if (!is_executable($file) && !install_fix_file($file, $mask)) {
               $return = FALSE;
             }
             break;
           case FILE_NOT_READABLE:
-            if (is_readable($file) && !drupal_install_fix_file($file, $mask)) {
+            if (is_readable($file) && !install_fix_file($file, $mask)) {
               $return = FALSE;
             }
             break;
           case FILE_NOT_WRITABLE:
-            if (is_writable($file) && !drupal_install_fix_file($file, $mask)) {
+            if (is_writable($file) && !install_fix_file($file, $mask)) {
               $return = FALSE;
             }
             break;
           case FILE_NOT_EXECUTABLE:
-            if (is_executable($file) && !drupal_install_fix_file($file, $mask)) {
+            if (is_executable($file) && !install_fix_file($file, $mask)) {
               $return = FALSE;
             }
             break;
@@ -889,7 +892,7 @@ function drupal_verify_install_file($file, $mask = NULL, $type = 'file') {
  * @return
  *  TRUE/FALSE whether or not the directory was successfully created.
  */
-function drupal_install_mkdir($file, $mask, $message = TRUE) {
+function install_mkdir($file, $mask, $message = TRUE) {
   $mod = 0;
   $masks = array(FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
   foreach ($masks as $m) {
@@ -937,7 +940,7 @@ function drupal_install_mkdir($file, $mask, $message = TRUE) {
  * @return
  *  TRUE/FALSE whether or not we were able to fix the file's permissions.
  */
-function drupal_install_fix_file($file, $mask, $message = TRUE) {
+function install_fix_file($file, $mask, $message = TRUE) {
   // If $file does not exist, fileperms() issues a PHP warning.
   if (!file_exists($file)) {
     return FALSE;
@@ -1006,9 +1009,9 @@ function drupal_install_fix_file($file, $mask, $message = TRUE) {
  * @param $path
  *   An installer path.
  */
-function install_goto($path) {
+function install_redirect($path) {
   global $base_url;
-  include_once DRUPAL_ROOT . '/core/includes/common.inc';
+  include_once ROOT . '/core/includes/common.inc';
   header('Location: ' . $base_url . '/' . $path);
   header('Cache-Control: no-cache'); // Not a permanent redirect.
   drupal_exit();
@@ -1037,11 +1040,11 @@ function install_goto($path) {
  *   passed-in $query. The URL is not sanitized, so it still needs to be run
  *   through check_url() if it will be used as an HTML attribute value.
  *
- * @see drupal_requirements_url()
+ * @see requirements_url()
  */
-function drupal_current_script_url($query = array()) {
+function current_script_url($query = array()) {
   $uri = $_SERVER['SCRIPT_NAME'];
-  $query = array_merge(drupal_get_query_parameters(), $query);
+  $query = array_merge(get_query_parameters(), $query);
   if (!empty($query)) {
     $uri .= '?' . drupal_http_build_query($query);
   }
@@ -1057,23 +1060,23 @@ function drupal_current_script_url($query = array()) {
  *
  * @param $severity
  *   The severity of the requirements problem, as returned by
- *   drupal_requirements_severity().
+ *   requirements_severity().
  *
  * @return
  *   A URL for attempting to proceed to the next step of the script. The URL is
  *   not sanitized, so it still needs to be run through check_url() if it will
  *   be used as an HTML attribute value.
  *
- * @see drupal_current_script_url()
+ * @see current_script_url()
  */
-function drupal_requirements_url($severity) {
+function requirements_url($severity) {
   $query = array();
   // If there are no errors, only warnings, append 'continue=1' to the URL so
   // the user can bypass this screen on the next page load.
   if ($severity == REQUIREMENT_WARNING) {
     $query['continue'] = 1;
   }
-  return drupal_current_script_url($query);
+  return current_script_url($query);
 }
 
 /**
@@ -1107,7 +1110,7 @@ function st($string, array $args = array(), array $options = array()) {
       // that multiple files end with the same extension, even if unlikely.
       $files = install_find_translation_files($install_state['parameters']['langcode']);
       if (!empty($files)) {
-        require_once DRUPAL_ROOT . '/core/includes/gettext.inc';
+        require_once ROOT . '/core/includes/gettext.inc';
         foreach ($files as $file) {
           _locale_import_read_po('mem-store', $file);
         }
@@ -1116,7 +1119,7 @@ function st($string, array $args = array(), array $options = array()) {
     }
   }
 
-  require_once DRUPAL_ROOT . '/core/includes/theme.inc';
+  require_once ROOT . '/core/includes/theme.inc';
   // Transform arguments before inserting them
   foreach ($args as $key => $value) {
     switch ($key[0]) {
@@ -1144,10 +1147,10 @@ function st($string, array $args = array(), array $options = array()) {
  * @return
  *   Array of the install profile's requirements.
  */
-function drupal_check_profile($profile) {
-  include_once DRUPAL_ROOT . '/core/includes/file.inc';
+function check_profile($profile) {
+  include_once ROOT . '/core/includes/file.inc';
 
-  $profile_file = DRUPAL_ROOT . "/profiles/$profile/$profile.profile";
+  $profile_file = ROOT . "/profiles/$profile/$profile.profile";
 
   if (!isset($profile) || !file_exists($profile_file)) {
     throw new Exception(install_no_profile_error());
@@ -1159,7 +1162,7 @@ function drupal_check_profile($profile) {
   $requirements = array();
   foreach ($info['dependencies'] as $module) {
     module_load_install($module);
-    $function = $module . '_requirements';
+    $function = 'Drupal\\' . $module . '_requirements';
     if (function_exists($function)) {
       $requirements = array_merge($requirements, $function('install'));
     }
@@ -1176,7 +1179,7 @@ function drupal_check_profile($profile) {
  * @return
  *   The highest severity in the array.
  */
-function drupal_requirements_severity(&$requirements) {
+function requirements_severity(&$requirements) {
   $severity = REQUIREMENT_OK;
   foreach ($requirements as $requirement) {
     if (isset($requirement['severity'])) {
@@ -1194,12 +1197,12 @@ function drupal_requirements_severity(&$requirements) {
  * @return
  *   TRUE/FALSE depending on the requirements are in place.
  */
-function drupal_check_module($module) {
+function check_module($module) {
   module_load_install($module);
   if (module_hook($module, 'requirements')) {
     // Check requirements
     $requirements = module_invoke($module, 'requirements', 'install');
-    if (is_array($requirements) && drupal_requirements_severity($requirements) == REQUIREMENT_ERROR) {
+    if (is_array($requirements) && requirements_severity($requirements) == REQUIREMENT_ERROR) {
       // Print any error messages
       foreach ($requirements as $requirement) {
         if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
@@ -1207,7 +1210,7 @@ function drupal_check_module($module) {
           if (isset($requirement['value']) && $requirement['value']) {
             $message .= ' (' . t('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) . ')';
           }
-          drupal_set_message($message, 'error');
+          set_message($message, 'error');
         }
       }
       return FALSE;
@@ -1262,16 +1265,16 @@ function install_profile_info($profile, $langcode = 'en') {
       'distribution_name' => 'Drupal',
       'version' => NULL,
       'hidden' => FALSE,
-      'php' => DRUPAL_MINIMUM_PHP,
+      'php' => MINIMUM_PHP,
     );
-    $info = drupal_parse_info_file("profiles/$profile/$profile.info") + $defaults;
+    $info = parse_info_file("profiles/$profile/$profile.info") + $defaults;
     $info['dependencies'] = array_unique(array_merge(
-      drupal_required_modules(),
+      required_modules(),
       $info['dependencies'],
       ($langcode != 'en' && !empty($langcode) ? array('locale') : array()))
     );
 
-    // drupal_required_modules() includes the current profile as a dependency.
+    // required_modules() includes the current profile as a dependency.
     // Since a module can't depend on itself we remove that element of the array.
     array_shift($info['dependencies']);
 
@@ -1301,6 +1304,6 @@ function db_run_tasks($driver) {
  */
 function db_installer_object($driver) {
   Database::loadDriverFile($driver, array('install.inc'));
-  $task_class = 'DatabaseTasks_' . $driver;
+  $task_class = 'Drupal\DatabaseTasks_' . $driver;
   return new $task_class();
 }
diff --git a/core/includes/language.inc b/core/includes/language.inc
index 4628053..6a3f98b 100644
--- a/core/includes/language.inc
+++ b/core/includes/language.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -23,7 +24,7 @@ function language_types_info() {
   if (!isset($language_types)) {
     $language_types = module_invoke_all('language_types_info');
     // Let other modules alter the list of language types.
-    drupal_alter('language_types_info', $language_types);
+    alter('language_types_info', $language_types);
   }
 
   return $language_types;
@@ -50,7 +51,7 @@ function language_types_configurable($stored = TRUE) {
   $configurable = &drupal_static(__FUNCTION__);
 
   if ($stored && !isset($configurable)) {
-    $types = variable_get('language_types', drupal_language_types());
+    $types = variable_get('language_types', _language_types());
     $configurable = array_keys(array_filter($types));
   }
 
@@ -74,7 +75,7 @@ function language_types_configurable($stored = TRUE) {
  *   An array of language types.
  */
 function language_types_disable($types) {
-  $enabled_types = variable_get('language_types', drupal_language_types());
+  $enabled_types = variable_get('language_types', _language_types());
 
   foreach ($types as $type) {
     unset($enabled_types[$type]);
@@ -90,8 +91,8 @@ function language_types_set() {
   // Ensure that we are getting the defined language negotiation information. An
   // invocation of module_enable() or module_disable() could outdate the cached
   // information.
-  drupal_static_reset('language_types_info');
-  drupal_static_reset('language_negotiation_info');
+  drupal_static_reset('Drupal\language_types_info');
+  drupal_static_reset('Drupal\language_negotiation_info');
 
   // Determine which language types are configurable and which not by checking
   // whether the 'fixed' key is defined. Non-configurable (fixed) language types
@@ -118,7 +119,7 @@ function language_types_set() {
 
   // Ensure that subsequent calls of language_types_configurable() return the
   // updated language type information.
-  drupal_static_reset('language_types_configurable');
+  drupal_static_reset('Drupal\language_types_configurable');
 }
 
 /**
@@ -193,15 +194,15 @@ function language_negotiation_get_switch_links($type, $path) {
   foreach ($negotiation as $id => $provider) {
     if (isset($provider['callbacks']['switcher'])) {
       if (isset($provider['file'])) {
-        require_once DRUPAL_ROOT . '/' . $provider['file'];
+        require_once ROOT . '/' . $provider['file'];
       }
 
-      $callback = $provider['callbacks']['switcher'];
+      $callback = 'Drupal\\' . $provider['callbacks']['switcher'];
       $result = $callback($type, $path);
 
       if (!empty($result)) {
         // Allow modules to provide translations for specific links.
-        drupal_alter('language_switch_links', $result, $type, $path);
+        alter('language_switch_links', $result, $type, $path);
         $links = (object) array('links' => $result, 'provider' => $id);
         break;
       }
@@ -218,8 +219,8 @@ function language_negotiation_purge() {
   // Ensure that we are getting the defined language negotiation information. An
   // invocation of module_enable() or module_disable() could outdate the cached
   // information.
-  drupal_static_reset('language_negotiation_info');
-  drupal_static_reset('language_types_info');
+  drupal_static_reset('Drupal\language_negotiation_info');
+  drupal_static_reset('Drupal\language_types_info');
 
   $defined_providers = language_negotiation_info();
   foreach (language_types_info() as $type => $type_info) {
@@ -305,7 +306,7 @@ function language_negotiation_info() {
     );
 
     // Let other modules alter the list of language providers.
-    drupal_alter('language_negotiation_info', $language_providers);
+    alter('language_negotiation_info', $language_providers);
   }
 
   return $language_providers;
@@ -338,13 +339,13 @@ function language_provider_invoke($provider_id, $provider = NULL) {
     }
 
     if (isset($provider['file'])) {
-      require_once DRUPAL_ROOT . '/' . $provider['file'];
+      require_once ROOT . '/' . $provider['file'];
     }
 
     // If the language provider has no cache preference or this is satisfied
     // we can execute the callback.
     $cache = !isset($provider['cache']) || $user->uid || $provider['cache'] == variable_get('cache', 0);
-    $callback = isset($provider['callbacks']['language']) ? $provider['callbacks']['language'] : FALSE;
+    $callback = isset($provider['callbacks']['language']) ? ('Drupal\\' . $provider['callbacks']['language']) : FALSE;
     $langcode = $cache && function_exists($callback) ? $callback($languages) : FALSE;
     $results[$provider_id] = isset($languages[$langcode]) ? $languages[$langcode] : FALSE;
   }
@@ -378,7 +379,7 @@ function language_provider_weight($provider) {
  * @return
  *   The negotiated language object.
  */
-function language_initialize($type) {
+function _language_initialize($type) {
   // Execute the language providers in the order they were set up and return the
   // first valid language found.
   $negotiation = variable_get("language_negotiation_$type", array());
@@ -458,7 +459,7 @@ function language_fallback_get_candidates($type = LANGUAGE_TYPE_CONTENT) {
     $fallback_candidates[] = LANGUAGE_NONE;
 
     // Let other modules hook in and add/change candidates.
-    drupal_alter('language_fallback_candidates', $fallback_candidates);
+    alter('language_fallback_candidates', $fallback_candidates);
   }
 
   return $fallback_candidates;
diff --git a/core/includes/locale.inc b/core/includes/locale.inc
index e2a79b6..fed9053 100644
--- a/core/includes/locale.inc
+++ b/core/includes/locale.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -374,7 +375,7 @@ function locale_language_switcher_url($type, $path) {
  * Return the session language switcher block.
  */
 function locale_language_switcher_session($type, $path) {
-  drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css');
+  add_css(get_path('module', 'locale') . '/locale.css');
 
   $param = variable_get('locale_language_negotiation_session_param', 'language');
   $language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : $GLOBALS[$type]->langcode;
@@ -409,11 +410,11 @@ function locale_language_switcher_session($type, $path) {
  * Rewrite URLs for the URL language provider.
  */
 function locale_language_url_rewrite_url(&$path, &$options) {
-  static $drupal_static_fast;
-  if (!isset($drupal_static_fast)) {
-    $drupal_static_fast['languages'] = &drupal_static(__FUNCTION__);
+  static $static_fast;
+  if (!isset($static_fast)) {
+    $static_fast['languages'] = &drupal_static(__FUNCTION__);
   }
-  $languages = &$drupal_static_fast['languages'];
+  $languages = &$static_fast['languages'];
 
   if (!isset($languages)) {
     // Get the enabled languages only.
@@ -508,7 +509,7 @@ function locale_language_url_rewrite_session(&$path, &$options) {
   // language preference even with cookies disabled.
   if ($query_rewrite) {
     if (is_string($options['query'])) {
-      $options['query'] = drupal_get_query_array($options['query']);
+      $options['query'] = get_query_array($options['query']);
     }
     if (!isset($options['query'][$query_param])) {
       $options['query'][$query_param] = $query_value;
@@ -733,7 +734,7 @@ function _locale_rebuild_js($langcode = NULL) {
     }
 
     $data .= "'strings': " . drupal_json_encode($translations) . " };";
-    $data_hash = drupal_hash_base64($data);
+    $data_hash = hash_base64($data);
   }
 
   // Construct the filepath where JS translation files are stored.
@@ -819,10 +820,10 @@ function _locale_rebuild_js($langcode = NULL) {
  *   An array of all country code => country name pairs.
  */
 function country_get_list() {
-  include_once DRUPAL_ROOT . '/core/includes/standard.inc';
+  include_once ROOT . '/core/includes/standard.inc';
   $countries = standard_country_list();
   // Allow other modules to modify the country list.
-  drupal_alter('countries', $countries);
+  alter('countries', $countries);
   return $countries;
 }
 
@@ -846,10 +847,10 @@ function locale_date_format_save($langcode, $type, $format) {
   $is_existing = (bool) db_query_range('SELECT 1 FROM {date_format_locale} WHERE language = :langcode AND type = :type', 0, 1, array(':langcode' => $langcode, ':type' => $type))->fetchField();
   if ($is_existing) {
     $keys = array('type', 'language');
-    drupal_write_record('date_format_locale', $locale_format, $keys);
+    write_record('date_format_locale', $locale_format, $keys);
   }
   else {
-    drupal_write_record('date_format_locale', $locale_format);
+    write_record('date_format_locale', $locale_format);
   }
 }
 
diff --git a/core/includes/lock.inc b/core/includes/lock.inc
index 7dd8db3..315e382 100644
--- a/core/includes/lock.inc
+++ b/core/includes/lock.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, PDO, PDOException;
 
 /**
  * @file
@@ -83,7 +85,7 @@ function _lock_id() {
     // Assign a unique id.
     $lock_id = uniqid(mt_rand(), TRUE);
     // We only register a shutdown function if a lock is used.
-    drupal_register_shutdown_function('lock_release_all', $lock_id);
+    drupal_register_shutdown_function('Drupal\lock_release_all', $lock_id);
   }
   return $lock_id;
 }
diff --git a/core/includes/mail.inc b/core/includes/mail.inc
index cf45ca5..1e10dcd 100644
--- a/core/includes/mail.inc
+++ b/core/includes/mail.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -20,7 +22,7 @@ define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER
  * appropriate places in the template. Processed e-mail templates are
  * requested from hook_mail() from the module sending the e-mail. Any module
  * can modify the composed e-mail message array using hook_mail_alter().
- * Finally drupal_mail_system()->mail() sends the e-mail, which can
+ * Finally mail_system()->mail() sends the e-mail, which can
  * be reused if the exact same composed e-mail is to be sent to multiple
  * recipients.
  *
@@ -46,8 +48,8 @@ define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER
  *   function example_notify($accounts) {
  *     foreach ($accounts as $account) {
  *       $params['account'] = $account;
- *       // example_mail() will be called based on the first drupal_mail() parameter.
- *       drupal_mail('example', 'notice', $account->mail, user_preferred_language($account), $params);
+ *       // example_mail() will be called based on the first mail() parameter.
+ *       mail('example', 'notice', $account->mail, user_preferred_language($account), $params);
  *     }
  *   }
  *
@@ -71,13 +73,13 @@ define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER
  *   }
  * @endcode
  *
- * Another example, which uses drupal_mail() to format a message for sending
+ * Another example, which uses mail() to format a message for sending
  * later:
  *
  * @code
  *   $params = array('current_conditions' => $data);
  *   $to = 'user@example.com';
- *   $message = drupal_mail('example', 'notice', $to, $language, $params, FALSE);
+ *   $message = mail('example', 'notice', $to, $language, $params, FALSE);
  *   // Only add to the spool if sending was not canceled.
  *   if ($message['send']) {
  *     example_spool_message($message);
@@ -105,7 +107,7 @@ define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER
  * @param $from
  *   Sets From to this value, if given.
  * @param $send
- *   If TRUE, drupal_mail() will call drupal_mail_system()->mail() to deliver
+ *   If TRUE, mail() will call mail_system()->mail() to deliver
  *   the message, and store the result in $message['result']. Modules
  *   implementing hook_mail_alter() may cancel sending by setting
  *   $message['send'] to FALSE.
@@ -117,7 +119,7 @@ define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER
  *   written to the watchdog. (Success means nothing more than the message being
  *   accepted at php-level, which still doesn't guarantee it to be delivered.)
  */
-function drupal_mail($module, $key, $to, $language, $params = array(), $from = NULL, $send = TRUE) {
+function mail($module, $key, $to, $language, $params = array(), $from = NULL, $send = TRUE) {
   $default_from = variable_get('site_mail', ini_get('sendmail_from'));
 
   // Bundle up the variables into a structured array for altering.
@@ -155,15 +157,15 @@ function drupal_mail($module, $key, $to, $language, $params = array(), $from = N
   // Build the e-mail (get subject and body, allow additional headers) by
   // invoking hook_mail() on this module. We cannot use module_invoke() as
   // we need to have $message by reference in hook_mail().
-  if (function_exists($function = $module . '_mail')) {
+  if (function_exists($function = 'Drupal\\' . $module . '_mail')) {
     $function($key, $message, $params);
   }
 
   // Invoke hook_mail_alter() to allow all modules to alter the resulting e-mail.
-  drupal_alter('mail', $message);
+  alter('mail', $message);
 
   // Retrieve the responsible implementation for this message.
-  $system = drupal_mail_system($module, $key);
+  $system = mail_system($module, $key);
 
   // Format the message body.
   $message = $system->format($message);
@@ -182,7 +184,7 @@ function drupal_mail($module, $key, $to, $language, $params = array(), $from = N
       // Log errors.
       if (!$message['result']) {
         watchdog('mail', 'Error sending e-mail (from %from to %to).', array('%from' => $message['from'], '%to' => $message['to']), WATCHDOG_ERROR);
-        drupal_set_message(t('Unable to send e-mail. Contact the site administrator if the problem persists.'), 'error');
+        set_message(t('Unable to send e-mail. Contact the site administrator if the problem persists.'), 'error');
       }
     }
   }
@@ -194,7 +196,7 @@ function drupal_mail($module, $key, $to, $language, $params = array(), $from = N
  * Returns an object that implements the MailSystemInterface.
  *
  * Allows for one or more custom mail backends to format and send mail messages
- * composed using drupal_mail().
+ * composed using mail().
  *
  * An implementation needs to implement the following methods:
  * - format: Allows to preprocess, format, and postprocess a mail
@@ -246,14 +248,14 @@ function drupal_mail($module, $key, $to, $language, $params = array(), $from = N
  * on the local server.
  *
  * @param $module
- *   The module name which was used by drupal_mail() to invoke hook_mail().
+ *   The module name which was used by mail() to invoke hook_mail().
  * @param $key
  *   A key to identify the e-mail sent. The final e-mail ID for the e-mail
- *   alter hook in drupal_mail() would have been {$module}_{$key}.
+ *   alter hook in mail() would have been {$module}_{$key}.
  *
  * @return MailSystemInterface
  */
-function drupal_mail_system($module, $key) {
+function mail_system($module, $key) {
   $instances = &drupal_static(__FUNCTION__, array());
 
   $id = $module . '_' . $key;
@@ -272,9 +274,11 @@ function drupal_mail_system($module, $key) {
     $class = $configuration['default-system'];
   }
 
+  $class = 'Drupal\\' . $class;
+
   if (empty($instances[$class])) {
     $interfaces = class_implements($class);
-    if (isset($interfaces['MailSystemInterface'])) {
+    if (isset($interfaces['Drupal\MailSystemInterface'])) {
       $instances[$class] = new $class();
     }
     else {
@@ -289,7 +293,7 @@ function drupal_mail_system($module, $key) {
  */
 interface MailSystemInterface {
   /**
-   * Format a message composed by drupal_mail() prior sending.
+   * Format a message composed by mail() prior sending.
    *
    * @param $message
    *   A message array, as described in hook_mail_alter().
@@ -300,7 +304,7 @@ interface MailSystemInterface {
    public function format(array $message);
 
   /**
-   * Send a message composed by drupal_mail().
+   * Send a message composed by mail().
    *
    * @param $message
    *   Message array with at least the following elements:
@@ -315,7 +319,7 @@ interface MailSystemInterface {
    *    - subject: Subject of the e-mail to be sent. This must not contain any
    *      newline characters, or the mail may not be sent properly.
    *    - body: Message to be sent. Accepts both CRLF and LF line-endings.
-   *      E-mail bodies must be wrapped. You can use drupal_wrap_mail() for
+   *      E-mail bodies must be wrapped. You can use wrap_mail() for
    *      smart plain text wrapping.
    *    - headers: Associative array containing all additional mail headers not
    *      defined by one of the other parameters.  PHP's mail() looks for Cc
@@ -333,7 +337,7 @@ interface MailSystemInterface {
  * We use delsp=yes wrapping, but only break non-spaced languages when
  * absolutely necessary to avoid compatibility issues.
  *
- * We deliberately use LF rather than CRLF, see drupal_mail().
+ * We deliberately use LF rather than CRLF, see mail().
  *
  * @param $text
  *   The plain text to process.
@@ -341,11 +345,11 @@ interface MailSystemInterface {
  *   A string to indent the text with. Only '>' characters are repeated on
  *   subsequent wrapped lines. Others are replaced by spaces.
  */
-function drupal_wrap_mail($text, $indent = '') {
+function wrap_mail($text, $indent = '') {
   // Convert CRLF into LF.
   $text = str_replace("\r", '', $text);
   // See if soft-wrapping is allowed.
-  $clean_indent = _drupal_html_to_text_clean($indent);
+  $clean_indent = _html_to_text_clean($indent);
   $soft = strpos($clean_indent, ' ') === FALSE;
   // Check if the string has line breaks.
   if (strpos($text, "\n") !== FALSE) {
@@ -353,12 +357,12 @@ function drupal_wrap_mail($text, $indent = '') {
     $text = preg_replace('/ +\n/m', "\n", $text);
     // Wrap each line at the needed width.
     $lines = explode("\n", $text);
-    array_walk($lines, '_drupal_wrap_mail_line', array('soft' => $soft, 'length' => strlen($indent)));
+    array_walk($lines, 'Drupal\_wrap_mail_line', array('soft' => $soft, 'length' => strlen($indent)));
     $text = implode("\n", $lines);
   }
   else {
     // Wrap this line.
-    _drupal_wrap_mail_line($text, 0, array('soft' => $soft, 'length' => strlen($indent)));
+    _wrap_mail_line($text, 0, array('soft' => $soft, 'length' => strlen($indent)));
   }
   // Empty lines with nothing but spaces.
   $text = preg_replace('/^ +\n/m', "\n", $text);
@@ -375,9 +379,9 @@ function drupal_wrap_mail($text, $indent = '') {
  * markup. Useful for preparing the body of a node to be sent by e-mail.
  *
  * The output will be suitable for use as 'format=flowed; delsp=yes' text
- * (RFC 3676) and can be passed directly to drupal_mail() for sending.
+ * (RFC 3676) and can be passed directly to mail() for sending.
  *
- * We deliberately use LF rather than CRLF, see drupal_mail().
+ * We deliberately use LF rather than CRLF, see mail().
  *
  * This function provides suitable alternatives for the following tags:
  * <a> <em> <i> <strong> <b> <br> <p> <blockquote> <ul> <ol> <li> <dl> <dt>
@@ -392,7 +396,7 @@ function drupal_wrap_mail($text, $indent = '') {
  * @return
  *   The transformed string.
  */
-function drupal_html_to_text($string, $allowed_tags = NULL) {
+function html_to_text($string, $allowed_tags = NULL) {
   // Cache list of supported tags.
   static $supported_tags;
   if (empty($supported_tags)) {
@@ -412,10 +416,10 @@ function drupal_html_to_text($string, $allowed_tags = NULL) {
   // Replace inline <a> tags with the text of link and a footnote.
   // 'See <a href="http://drupal.org">the Drupal site</a>' becomes
   // 'See the Drupal site [1]' with the URL included as a footnote.
-  _drupal_html_to_mail_urls(NULL, TRUE);
+  _html_to_mail_urls(NULL, TRUE);
   $pattern = '@(<a[^>]+?href="([^"]*)"[^>]*?>(.+?)</a>)@i';
-  $string = preg_replace_callback($pattern, '_drupal_html_to_mail_urls', $string);
-  $urls = _drupal_html_to_mail_urls();
+  $string = preg_replace_callback($pattern, 'Drupal\_html_to_mail_urls', $string);
+  $urls = _html_to_mail_urls();
   $footnotes = '';
   if (count($urls)) {
     $footnotes .= "\n";
@@ -503,7 +507,7 @@ function drupal_html_to_text($string, $allowed_tags = NULL) {
         case '/h2':
           $casing = NULL;
           // Pad the line with dashes.
-          $output = _drupal_html_to_text_pad($output, ($tagname == '/h1') ? '=' : '-', ' ');
+          $output = _html_to_text_pad($output, ($tagname == '/h1') ? '=' : '-', ' ');
           array_pop($indent);
           $chunk = ''; // Ensure blank new-line.
           break;
@@ -511,8 +515,8 @@ function drupal_html_to_text($string, $allowed_tags = NULL) {
         // Horizontal rulers
         case 'hr':
           // Insert immediately.
-          $output .= drupal_wrap_mail('', implode('', $indent)) . "\n";
-          $output = _drupal_html_to_text_pad($output, '-');
+          $output .= wrap_mail('', implode('', $indent)) . "\n";
+          $output = _html_to_text_pad($output, '-');
           break;
 
         // Paragraphs and definition lists
@@ -536,12 +540,13 @@ function drupal_html_to_text($string, $allowed_tags = NULL) {
     if (isset($chunk)) {
       // Apply any necessary case conversion.
       if (isset($casing)) {
-        $chunk = $casing($chunk);
+        $function = 'Drupal\\' . $casing;
+        $chunk = $function($chunk);
       }
       // Format it and apply the current indentation.
-      $output .= drupal_wrap_mail($chunk, implode('', $indent)) . MAIL_LINE_ENDINGS;
+      $output .= wrap_mail($chunk, implode('', $indent)) . MAIL_LINE_ENDINGS;
       // Remove non-quotation markers from indentation.
-      $indent = array_map('_drupal_html_to_text_clean', $indent);
+      $indent = array_map('Drupal\_html_to_text_clean', $indent);
     }
 
     $tag = !$tag;
@@ -551,11 +556,11 @@ function drupal_html_to_text($string, $allowed_tags = NULL) {
 }
 
 /**
- * Helper function for array_walk in drupal_wrap_mail().
+ * Helper function for array_walk in wrap_mail().
  *
  * Wraps words on a single line.
  */
-function _drupal_wrap_mail_line(&$line, $key, $values) {
+function _wrap_mail_line(&$line, $key, $values) {
   // Use soft-breaks only for purely quoted or unindented text.
   $line = wordwrap($line, 77 - $values['length'], $values['soft'] ? "  \n" : "\n");
   // Break really long words at the maximum width allowed.
@@ -563,11 +568,11 @@ function _drupal_wrap_mail_line(&$line, $key, $values) {
 }
 
 /**
- * Helper function for drupal_html_to_text().
+ * Helper function for html_to_text().
  *
  * Keeps track of URLs and replaces them with placeholder tokens.
  */
-function _drupal_html_to_mail_urls($match = NULL, $reset = FALSE) {
+function _html_to_mail_urls($match = NULL, $reset = FALSE) {
   global $base_url, $base_path;
   static $urls = array(), $regexp;
 
@@ -590,20 +595,20 @@ function _drupal_html_to_mail_urls($match = NULL, $reset = FALSE) {
 }
 
 /**
- * Helper function for drupal_wrap_mail() and drupal_html_to_text().
+ * Helper function for wrap_mail() and html_to_text().
  *
  * Replace all non-quotation markers from a given piece of indentation with spaces.
  */
-function _drupal_html_to_text_clean($indent) {
+function _html_to_text_clean($indent) {
   return preg_replace('/[^>]/', ' ', $indent);
 }
 
 /**
- * Helper function for drupal_html_to_text().
+ * Helper function for html_to_text().
  *
  * Pad the last line with the given character.
  */
-function _drupal_html_to_text_pad($text, $pad, $prefix = '') {
+function _html_to_text_pad($text, $pad, $prefix = '') {
   // Remove last line break.
   $text = substr($text, 0, -1);
   // Calculate needed padding space and add it.
diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index 40f9bfe..8093b46 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, PDO;
 
 /**
  * @file
@@ -462,7 +464,7 @@ function menu_get_item($path = NULL, $router_item = NULL) {
     if ($router_item) {
       // Allow modules to alter the router item before it is translated and
       // checked for access.
-      drupal_alter('menu_get_item', $router_item, $path, $original_map);
+      alter('menu_get_item', $router_item, $path, $original_map);
 
       $map = _menu_translate($router_item, $original_map);
       $router_item['original_map'] = $original_map;
@@ -500,16 +502,16 @@ function menu_execute_active_handler($path = NULL, $deliver = TRUE) {
   // would not change the global variable. hook_url_inbound_alter() can be used
   // to change the path. Code later will not use the $read_only_path variable.
   $read_only_path = !empty($path) ? $path : $_GET['q'];
-  drupal_alter('menu_site_status', $page_callback_result, $read_only_path);
+  alter('menu_site_status', $page_callback_result, $read_only_path);
 
   // Only continue if the site status is not set.
   if ($page_callback_result == MENU_SITE_ONLINE) {
     if ($router_item = menu_get_item($path)) {
       if ($router_item['access']) {
         if ($router_item['include_file']) {
-          require_once DRUPAL_ROOT . '/' . $router_item['include_file'];
+          require_once ROOT . '/' . $router_item['include_file'];
         }
-        $page_callback_result = call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
+        $page_callback_result = call_user_func_array('Drupal\\' . $router_item['page_callback'], $router_item['page_arguments']);
       }
       else {
         $page_callback_result = MENU_ACCESS_DENIED;
@@ -524,7 +526,7 @@ function menu_execute_active_handler($path = NULL, $deliver = TRUE) {
   // return it raw, so calling code can do more processing.
   if ($deliver) {
     $default_delivery_callback = (isset($router_item) && $router_item) ? $router_item['delivery_callback'] : NULL;
-    drupal_deliver_page($page_callback_result, $default_delivery_callback);
+    deliver_page($page_callback_result, $default_delivery_callback);
   }
   else {
     return $page_callback_result;
@@ -562,6 +564,7 @@ function _menu_load_objects(&$item, &$map) {
           // some processing. In this case the $function is the key to the
           // load_function array, and the value is the list of arguments.
           list($function, $args) = each($function);
+          $function = 'Drupal\\' . $function;
           $load_functions[$index] = $function;
 
           // Some arguments are placeholders for dynamic items to process.
@@ -585,6 +588,7 @@ function _menu_load_objects(&$item, &$map) {
           $return = call_user_func_array($function, $args);
         }
         else {
+          $function = 'Drupal\\' . $function;
           $return = $function($value);
         }
         // If callback returned an error or there is no callback, trigger 404.
@@ -628,7 +632,7 @@ function _menu_check_access(&$item, $map) {
       $item['access'] = (count($arguments) == 1) ? user_access($arguments[0]) : user_access($arguments[0], $arguments[1]);
     }
     else {
-      $item['access'] = call_user_func_array($callback, $arguments);
+      $item['access'] = call_user_func_array('Drupal\\' . $callback, $arguments);
     }
   }
 }
@@ -688,11 +692,12 @@ function _menu_item_localize(&$item, $map, $link_translate = FALSE) {
       }
     }
     elseif ($callback) {
+      $function = 'Drupal\\' . $callback;
       if (empty($item['title_arguments'])) {
-        $item['title'] = $callback($item['title']);
+        $item['title'] = $function($item['title']);
       }
       else {
-        $item['title'] = call_user_func_array($callback, menu_unserialize($item['title_arguments'], $map));
+        $item['title'] = call_user_func_array($function, menu_unserialize($item['title_arguments'], $map));
       }
       // Avoid calling check_plain again on l() function.
       if ($callback == 'check_plain') {
@@ -805,6 +810,7 @@ function _menu_link_map_translate(&$map, $to_arg_functions) {
   $to_arg_functions = unserialize($to_arg_functions);
   foreach ($to_arg_functions as $index => $function) {
     // Translate place-holders into real values.
+    $function = 'Drupal\\' . $function;
     $arg = $function(!empty($map[$index]) ? $map[$index] : '', $map, $index);
     if (!empty($map[$index]) || isset($arg)) {
       $map[$index] = $arg;
@@ -928,7 +934,7 @@ function _menu_link_translate(&$item, $translate = FALSE) {
   // options array. For performance reasons we only invoke this hook if the link
   // has the 'alter' flag set in the options array.
   if (!empty($item['options']['alter'])) {
-    drupal_alter('translated_menu_link', $item, $map);
+    alter('translated_menu_link', $item, $map);
   }
 
   return $map;
@@ -1622,7 +1628,7 @@ function theme_menu_link(array $variables) {
     $sub_menu = drupal_render($element['#below']);
   }
   $output = l($element['#title'], $element['#href'], $element['#localized_options']);
-  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
+  return '<li' . attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
 }
 
 /**
@@ -1689,7 +1695,7 @@ function theme_menu_local_action($variables) {
 /**
  * Generates elements for the $arg array in the help hook.
  */
-function drupal_help_arg($arg = array()) {
+function help_arg($arg = array()) {
   // Note - the number of empty elements should be > MENU_MAX_PARTS.
   return $arg + array('', '', '', '', '', '', '', '', '', '', '', '');
 }
@@ -1705,10 +1711,10 @@ function menu_get_active_help() {
     return '';
   }
 
-  $arg = drupal_help_arg(arg(NULL));
+  $arg = help_arg(arg(NULL));
 
   foreach (module_implements('help') as $module) {
-    $function = $module . '_help';
+    $function = 'Drupal\\' . $module . '_help';
     // Lookup help for this path.
     if ($help = $function($router_path, $arg)) {
       $output .= $help . "\n";
@@ -1737,7 +1743,7 @@ function menu_get_custom_theme($initialize = FALSE) {
     // First allow modules to dynamically set a custom theme for the current
     // page. Since we can only have one, the last module to return a valid
     // theme takes precedence.
-    $custom_themes = array_filter(module_invoke_all('custom_theme'), 'drupal_theme_access');
+    $custom_themes = array_filter(module_invoke_all('custom_theme'), 'Drupal\theme_access');
     if (!empty($custom_themes)) {
       $custom_theme = array_pop($custom_themes);
     }
@@ -1746,8 +1752,8 @@ function menu_get_custom_theme($initialize = FALSE) {
     // by a hook_custom_theme() implementation above.
     $router_item = menu_get_item();
     if (!empty($router_item['access']) && !empty($router_item['theme_callback'])) {
-      $theme_name = call_user_func_array($router_item['theme_callback'], $router_item['theme_arguments']);
-      if (drupal_theme_access($theme_name)) {
+      $theme_name = call_user_func_array('Drupal\\' . $router_item['theme_callback'], $router_item['theme_arguments']);
+      if (theme_access($theme_name)) {
         $custom_theme = $theme_name;
       }
     }
@@ -2070,7 +2076,7 @@ function menu_local_tasks($level = 0) {
     $data['tabs'] = $tabs;
 
     // Allow modules to alter local tasks or dynamically append further tasks.
-    drupal_alter('menu_local_tasks', $data, $router_item, $root_path);
+    alter('menu_local_tasks', $data, $router_item, $root_path);
   }
 
   if (isset($data['tabs'][$level])) {
@@ -2178,7 +2184,7 @@ function menu_contextual_links($module, $parent_path, $args) {
   }
 
   // Allow modules to alter contextual links.
-  drupal_alter('menu_contextual_links', $links, $router_item, $root_path);
+  alter('menu_contextual_links', $links, $router_item, $root_path);
 
   // Performance: If the current user does not have access to any links for this
   // router path and no other module added further links, we assign FALSE here
@@ -2308,7 +2314,7 @@ function menu_set_active_item($path) {
  * Any trail set by this function will only be used for functionality that calls
  * menu_get_active_trail(). Drupal core only uses trails set here for
  * breadcrumbs and the page title and not for menu trees or page content.
- * Additionally, breadcrumbs set by drupal_set_breadcrumb() will override any
+ * Additionally, breadcrumbs set by set_breadcrumb() will override any
  * trail set here.
  *
  * To affect the trail used by menu trees, use menu_tree_set_path(). To affect
@@ -2385,7 +2391,7 @@ function menu_set_active_trail($new_trail = NULL) {
     // appending either the preferred link or the menu router item for the
     // current page. Exclude it if we are on the front page.
     $last = end($trail);
-    if ($last['href'] != $preferred_link['href'] && !drupal_is_front_page()) {
+    if ($last['href'] != $preferred_link['href'] && !is_front_page()) {
       $trail[] = $preferred_link;
     }
   }
@@ -2521,7 +2527,7 @@ function menu_get_active_breadcrumb() {
   $breadcrumb = array();
 
   // No breadcrumb for the front page.
-  if (drupal_is_front_page()) {
+  if (is_front_page()) {
     return $breadcrumb;
   }
 
@@ -2531,7 +2537,7 @@ function menu_get_active_breadcrumb() {
 
     // Allow modules to alter the breadcrumb, if possible, as that is much
     // faster than rebuilding an entirely new active trail.
-    drupal_alter('menu_breadcrumb', $active_trail, $item);
+    alter('menu_breadcrumb', $active_trail, $item);
 
     // Don't show a link to the current page in the breadcrumb trail.
     $end = end($active_trail);
@@ -2630,12 +2636,12 @@ function menu_cache_clear_all() {
  * Resets the menu system static cache.
  */
 function menu_reset_static_cache() {
-  drupal_static_reset('_menu_build_tree');
-  drupal_static_reset('menu_tree');
-  drupal_static_reset('menu_tree_all_data');
-  drupal_static_reset('menu_tree_page_data');
-  drupal_static_reset('menu_load_all');
-  drupal_static_reset('menu_link_get_preferred');
+  drupal_static_reset('Drupal\_menu_build_tree');
+  drupal_static_reset('Drupal\menu_tree');
+  drupal_static_reset('Drupal\menu_tree_all_data');
+  drupal_static_reset('Drupal\menu_tree_page_data');
+  drupal_static_reset('Drupal\menu_load_all');
+  drupal_static_reset('Drupal\menu_link_get_preferred');
 }
 
 /**
@@ -2687,7 +2693,7 @@ function menu_router_build() {
   // a given item came from.
   $callbacks = array();
   foreach (module_implements('menu') as $module) {
-    $router_items = call_user_func($module . '_menu');
+    $router_items = call_user_func('Drupal\\' . $module . '_menu');
     if (isset($router_items) && is_array($router_items)) {
       foreach (array_keys($router_items) as $path) {
         $router_items[$path]['module'] = $module;
@@ -2696,7 +2702,7 @@ function menu_router_build() {
     }
   }
   // Alter the menu as defined in modules, keys are like user/%user.
-  drupal_alter('menu', $callbacks);
+  alter('menu', $callbacks);
   list($menu, $masks) = _menu_router_build($callbacks);
   _menu_router_cache($menu);
 
@@ -2985,7 +2991,7 @@ function _menu_delete_item($item, $force = FALSE) {
  * @param $item
  *   An associative array representing a menu link item, with elements:
  *   - link_path: (required) The path of the menu item, which should be
- *     normalized first by calling drupal_get_normal_path() on it.
+ *     normalized first by calling get_normal_path() on it.
  *   - link_title: (required) Title to appear in menu for the link.
  *   - menu_name: (optional) The machine name of the menu for the link.
  *     Defaults to 'navigation'.
@@ -3008,7 +3014,7 @@ function _menu_delete_item($item, $force = FALSE) {
  *   saved.
  */
 function menu_link_save(&$item, $existing_item = array(), $parent_candidates = array()) {
-  drupal_alter('menu_link', $item);
+  alter('menu_link', $item);
 
   // This is the easiest way to handle the unique internal path '<front>',
   // since a path marked as external does not need to match a router path.
@@ -3254,9 +3260,9 @@ function _menu_clear_page_cache() {
     $cache_cleared = 1;
   }
   elseif ($cache_cleared == 1) {
-    drupal_register_shutdown_function('cache_clear_all');
+    drupal_register_shutdown_function('Drupal\cache_clear_all');
     // Keep track of which menus have expanded items.
-    drupal_register_shutdown_function('_menu_set_expanded_menus');
+    drupal_register_shutdown_function('Drupal\_menu_set_expanded_menus');
     $cache_cleared = 2;
   }
 }
@@ -3498,18 +3504,18 @@ function _menu_router_build($callbacks) {
       $match = FALSE;
       // Look for wildcards in the form allowed to be used in PHP functions,
       // because we are using these to construct the load function names.
-      if (preg_match('/^%(|' . DRUPAL_PHP_FUNCTION_PATTERN . ')$/', $part, $matches)) {
+      if (preg_match('/^%(|' . PHP_FUNCTION_PATTERN . ')$/', $part, $matches)) {
         if (empty($matches[1])) {
           $match = TRUE;
           $load_functions[$k] = NULL;
         }
         else {
-          if (function_exists($matches[1] . '_to_arg')) {
+          if (function_exists('Drupal\\' . $matches[1] . '_to_arg')) {
             $to_arg_functions[$k] = $matches[1] . '_to_arg';
             $load_functions[$k] = NULL;
             $match = TRUE;
           }
-          if (function_exists($matches[1] . '_load')) {
+          if (function_exists('Drupal\\' . $matches[1] . '_load')) {
             $function = $matches[1] . '_load';
             // Create an array of arguments that will be passed to the _load
             // function when this menu path is checked, if 'load arguments'
@@ -3622,7 +3628,7 @@ function _menu_router_build($callbacks) {
           if (!isset($item['file']) && isset($parent['file'])) {
             $item['file'] = $parent['file'];
             if (empty($item['file path']) && isset($item['module']) && isset($parent['module']) && $item['module'] != $parent['module']) {
-              $item['file path'] = drupal_get_path('module', $parent['module']);
+              $item['file path'] = get_path('module', $parent['module']);
             }
           }
         }
@@ -3689,7 +3695,7 @@ function _menu_router_build($callbacks) {
 
     // Calculate out the file to be included for each callback, if any.
     if ($item['file']) {
-      $file_path = $item['file path'] ? $item['file path'] : drupal_get_path('module', $item['module']);
+      $file_path = $item['file path'] ? $item['file path'] : get_path('module', $item['module']);
       $item['include file'] = $file_path . '/' . $item['file'];
     }
   }
@@ -3807,10 +3813,10 @@ function _menu_site_is_offline($check_only = FALSE) {
       // the maintenance mode settings page.
       if (!$check_only && $_GET['q'] != 'admin/config/development/maintenance') {
         if (user_access('administer site configuration')) {
-          drupal_set_message(t('Operating in maintenance mode. <a href="@url">Go online.</a>', array('@url' => url('admin/config/development/maintenance'))), 'status', FALSE);
+          set_message(t('Operating in maintenance mode. <a href="@url">Go online.</a>', array('@url' => url('admin/config/development/maintenance'))), 'status', FALSE);
         }
         else {
-          drupal_set_message(t('Operating in maintenance mode.'), 'status', FALSE);
+          set_message(t('Operating in maintenance mode.'), 'status', FALSE);
         }
       }
     }
diff --git a/core/includes/module.inc b/core/includes/module.inc
index 1a52a80..c639802 100644
--- a/core/includes/module.inc
+++ b/core/includes/module.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -21,7 +22,7 @@ function module_load_all($bootstrap = FALSE) {
 
   if (isset($bootstrap)) {
     foreach (module_list(TRUE, $bootstrap) as $module) {
-      drupal_load('module', $module);
+      load('module', $module);
     }
     // $has_run will be TRUE if $bootstrap is FALSE.
     $has_run = !$bootstrap;
@@ -71,7 +72,7 @@ function module_list($refresh = FALSE, $bootstrap_refresh = FALSE, $sort = FALSE
     $sorted_list = NULL;
     if ($fixed_list) {
       foreach ($fixed_list as $name => $module) {
-        drupal_get_filename('module', $name, $module['filename']);
+        get_filename('module', $name, $module['filename']);
         $list[$name] = $name;
       }
     }
@@ -79,13 +80,13 @@ function module_list($refresh = FALSE, $bootstrap_refresh = FALSE, $sort = FALSE
       if ($refresh) {
         // For the $refresh case, make sure that system_list() returns fresh
         // data.
-        drupal_static_reset('system_list');
+        drupal_static_reset('Drupal\system_list');
       }
       if ($bootstrap_refresh) {
         $list = system_list('bootstrap');
       }
       else {
-        // Not using drupal_map_assoc() here as that requires common.inc.
+        // Not using map_assoc() here as that requires common.inc.
         $list = array_keys(system_list('module_enabled'));
         $list = (!empty($list) ? array_combine($list, $list) : array());
       }
@@ -137,10 +138,10 @@ function system_list($type) {
       cache('bootstrap')->set('bootstrap_modules', $bootstrap_list);
     }
     // To avoid a separate database lookup for the filepath, prime the
-    // drupal_get_filename() static cache for bootstrap modules only.
+    // get_filename() static cache for bootstrap modules only.
     // The rest is stored separately to keep the bootstrap module cache small.
     foreach ($bootstrap_list as $module) {
-      drupal_get_filename('module', $module->name, $module->filename);
+      get_filename('module', $module->name, $module->filename);
     }
     // We only return the module names here since module_list() doesn't need
     // the filename itself.
@@ -173,7 +174,7 @@ function system_list($type) {
         if ($record->type == 'theme') {
           $lists['theme'][$record->name] = $record;
         }
-        // Build a list of filenames so drupal_get_filename can use it.
+        // Build a list of filenames so get_filename can use it.
         if ($record->status) {
           $lists['filepaths'][] = array('type' => $record->type, 'name' => $record->name, 'filepath' => $record->filename);
         }
@@ -181,9 +182,9 @@ function system_list($type) {
       cache('bootstrap')->set('system_list', $lists);
     }
     // To avoid a separate database lookup for the filepath, prime the
-    // drupal_get_filename() static cache with all enabled modules and themes.
+    // get_filename() static cache with all enabled modules and themes.
     foreach ($lists['filepaths'] as $item) {
-      drupal_get_filename($item['type'], $item['name'], $item['filepath']);
+      get_filename($item['type'], $item['name'], $item['filepath']);
     }
   }
 
@@ -194,9 +195,9 @@ function system_list($type) {
  * Reset all system_list() caches.
  */
 function system_list_reset() {
-  drupal_static_reset('system_list');
-  drupal_static_reset('system_rebuild_module_data');
-  drupal_static_reset('list_themes');
+  drupal_static_reset('Drupal\system_list');
+  drupal_static_reset('Drupal\system_rebuild_module_data');
+  drupal_static_reset('Drupal\list_themes');
   cache('bootstrap')->deleteMultiple(array('bootstrap_modules', 'system_list'));
 }
 
@@ -214,17 +215,17 @@ function system_list_reset() {
  *     without this module.
  */
 function _module_build_dependencies($files) {
-  require_once DRUPAL_ROOT . '/core/includes/graph.inc';
+  require_once ROOT . '/core/includes/graph.inc';
   foreach ($files as $filename => $file) {
     $graph[$file->name]['edges'] = array();
     if (isset($file->info['dependencies']) && is_array($file->info['dependencies'])) {
       foreach ($file->info['dependencies'] as $dependency) {
-        $dependency_data = drupal_parse_dependency($dependency);
+        $dependency_data = parse_dependency($dependency);
         $graph[$file->name]['edges'][$dependency_data['name']] = $dependency_data;
       }
     }
   }
-  drupal_depth_first_search($graph);
+  depth_first_search($graph);
   foreach ($graph as $module => $data) {
     $files[$module]->required_by = isset($data['reverse_paths']) ? $data['reverse_paths'] : array();
     $files[$module]->requires = isset($data['paths']) ? $data['paths'] : array();
@@ -258,7 +259,7 @@ function module_exists($module) {
  */
 function module_load_install($module) {
   // Make sure the installation API is available
-  include_once DRUPAL_ROOT . '/core/includes/install.inc';
+  include_once ROOT . '/core/includes/install.inc';
 
   return module_load_include('install', $module);
 }
@@ -276,7 +277,7 @@ function module_load_install($module) {
  *
  * Do not use this function to load an install file, use module_load_install()
  * instead. Do not use this function in a global context since it requires
- * Drupal to be fully bootstrapped, use require_once DRUPAL_ROOT . '/path/file'
+ * Drupal to be fully bootstrapped, use require_once ROOT . '/path/file'
  * instead.
  *
  * @param $type
@@ -295,8 +296,8 @@ function module_load_include($type, $module, $name = NULL) {
     $name = $module;
   }
 
-  if (function_exists('drupal_get_path')) {
-    $file = DRUPAL_ROOT . '/' . drupal_get_path('module', $module) . "/$name.$type";
+  if (function_exists('Drupal\get_path')) {
+    $file = ROOT . '/' . get_path('module', $module) . "/$name.$type";
     if (is_file($file)) {
       require_once $file;
       return $file;
@@ -391,7 +392,7 @@ function module_enable($module_list, $enable_dependencies = TRUE) {
   }
 
   // Required for module installation checks.
-  include_once DRUPAL_ROOT . '/core/includes/install.inc';
+  include_once ROOT . '/core/includes/install.inc';
 
   $modules_installed = array();
   $modules_enabled = array();
@@ -403,7 +404,7 @@ function module_enable($module_list, $enable_dependencies = TRUE) {
       ->fetchObject();
     if ($existing->status == 0) {
       // Load the module's code.
-      drupal_load('module', $module);
+      load('module', $module);
       module_load_install($module);
 
       // Update the database and module list to reflect the new module. This
@@ -423,18 +424,18 @@ function module_enable($module_list, $enable_dependencies = TRUE) {
       // Update the registry to include it.
       registry_update();
       // Refresh the schema to include it.
-      drupal_get_schema(NULL, TRUE);
+      get_schema(NULL, TRUE);
 
       // Allow modules to react prior to the installation of a module.
       module_invoke_all('modules_preinstall', array($module));
 
       // Now install the module if necessary.
-      if (drupal_get_installed_schema_version($module, TRUE) == SCHEMA_UNINSTALLED) {
-        drupal_install_schema($module);
+      if (get_installed_schema_version($module, TRUE) == SCHEMA_UNINSTALLED) {
+        install_schema($module);
 
         // Set the schema version to the number of the last update provided
         // by the module.
-        $versions = drupal_get_schema_versions($module);
+        $versions = get_schema_versions($module);
         $version = $versions ? max($versions) : SCHEMA_INSTALLED;
 
         // If the module has no current updates, but has some that were
@@ -443,7 +444,7 @@ function module_enable($module_list, $enable_dependencies = TRUE) {
         if ($last_removed = module_invoke($module, 'update_last_removed')) {
           $version = max($version, $last_removed);
         }
-        drupal_set_installed_schema_version($module, $version);
+        set_installed_schema_version($module, $version);
         // Allow the module to perform install tasks.
         module_invoke($module, 'install');
         // Record the fact that it was installed.
@@ -493,7 +494,7 @@ function module_disable($module_list, $disable_dependents = TRUE) {
     // Create an associative array with weights as values.
     $module_list = array_flip(array_values($module_list));
 
-    $profile = drupal_get_profile();
+    $profile = get_profile();
     while (list($module) = each($module_list)) {
       if (!isset($module_data[$module]) || !$module_data[$module]->status) {
         // This module doesn't exist or is already disabled, skip it.
@@ -586,7 +587,7 @@ function module_disable($module_list, $disable_dependents = TRUE) {
  *   implemented in that module.
  */
 function module_hook($module, $hook) {
-  $function = $module . '_' . $hook;
+  $function = 'Drupal\\' . $module . '_' . $hook;
   if (function_exists($function)) {
     return TRUE;
   }
@@ -618,11 +619,11 @@ function module_hook($module, $hook) {
  */
 function module_implements($hook, $sort = FALSE) {
   // Use the advanced drupal_static() pattern, since this is called very often.
-  static $drupal_static_fast;
-  if (!isset($drupal_static_fast)) {
-    $drupal_static_fast['implementations'] = &drupal_static(__FUNCTION__);
+  static $static_fast;
+  if (!isset($static_fast)) {
+    $static_fast['implementations'] = &drupal_static(__FUNCTION__);
   }
-  $implementations = &$drupal_static_fast['implementations'];
+  $implementations = &$static_fast['implementations'];
 
   // Fetch implementations from cache.
   if (empty($implementations)) {
@@ -646,14 +647,14 @@ function module_implements($hook, $sort = FALSE) {
       $include_file = isset($hook_info[$hook]['group']) && module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']);
       // Since module_hook() may needlessly try to load the include file again,
       // function_exists() is used directly here.
-      if (function_exists($module . '_' . $hook)) {
+      if (function_exists('Drupal\\' . $module . '_' . $hook)) {
         $implementations[$hook][$module] = $include_file ? $hook_info[$hook]['group'] : FALSE;
       }
     }
     // Allow modules to change the weight of specific implementations but avoid
     // an infinite loop.
     if ($hook != 'module_implements_alter') {
-      drupal_alter('module_implements', $implementations[$hook], $hook);
+      alter('module_implements', $implementations[$hook], $hook);
     }
   }
   else {
@@ -668,7 +669,7 @@ function module_implements($hook, $sort = FALSE) {
       // function exists on each request to avoid undefined function errors.
       // Since module_hook() may needlessly try to load the include file again,
       // function_exists() is used directly here.
-      if (!function_exists($module . '_' . $hook)) {
+      if (!function_exists('Drupal\\' . $module . '_' . $hook)) {
         // Clear out the stale implementation from the cache and force a cache
         // refresh to forget about no longer existing hook implementations.
         unset($implementations[$hook][$module]);
@@ -694,10 +695,10 @@ function module_implements_reset() {
   // gains when a large number of modules are installed or hooks invoked, since
   // this can quickly lead to module_hook() being called several thousand times
   // per request.
-  drupal_static_reset('module_implements');
+  drupal_static_reset('Drupal\module_implements');
   cache('bootstrap')->set('module_implements', array());
-  drupal_static_reset('module_hook_info');
-  drupal_static_reset('drupal_alter');
+  drupal_static_reset('Drupal\module_hook_info');
+  drupal_static_reset('Drupal\alter');
   cache('bootstrap')->delete('hook_info');
 }
 
@@ -709,7 +710,7 @@ function module_hook_info() {
   // case common.inc, subsystems, and modules are not loaded yet, so it does not
   // make sense to support hook groups resp. lazy-loaded include files prior to
   // full bootstrap.
-  if (drupal_bootstrap(NULL, FALSE) != DRUPAL_BOOTSTRAP_FULL) {
+  if (bootstrap(NULL, FALSE) != BOOTSTRAP_FULL) {
     return array();
   }
   $hook_info = &drupal_static(__FUNCTION__);
@@ -722,7 +723,7 @@ function module_hook_info() {
       // We can't use module_invoke_all() here or it would cause an infinite
       // loop.
       foreach (module_list() as $module) {
-        $function = $module . '_hook_info';
+        $function = 'Drupal\\' . $module . '_hook_info';
         if (function_exists($function)) {
           $result = $function();
           if (isset($result) && is_array($result)) {
@@ -730,9 +731,9 @@ function module_hook_info() {
           }
         }
       }
-      // We can't use drupal_alter() for the same reason as above.
+      // We can't use alter() for the same reason as above.
       foreach (module_list() as $module) {
-        $function = $module . '_hook_info_alter';
+        $function = 'Drupal\\' . $module . '_hook_info_alter';
         if (function_exists($function)) {
           $function($hook_info);
         }
@@ -753,7 +754,7 @@ function module_hook_info() {
  * @see module_implements()
  */
 function module_implements_write_cache() {
-  $implementations = &drupal_static('module_implements');
+  $implementations = &drupal_static('Drupal\module_implements');
   // Check whether we need to write the cache. We do not want to cache hooks
   // which are only invoked on HTTP POST requests since these do not need to be
   // optimized as tightly, and not doing so keeps the cache entry smaller.
@@ -781,7 +782,7 @@ function module_invoke($module, $hook) {
   // Remove $module and $hook from the arguments.
   unset($args[0], $args[1]);
   if (module_hook($module, $hook)) {
-    return call_user_func_array($module . '_' . $hook, $args);
+    return call_user_func_array('Drupal\\' . $module . '_' . $hook, $args);
   }
 }
 
@@ -803,7 +804,7 @@ function module_invoke_all($hook) {
   unset($args[0]);
   $return = array();
   foreach (module_implements($hook) as $module) {
-    $function = $module . '_' . $hook;
+    $function = 'Drupal\\' . $module . '_' . $hook;
     if (function_exists($function)) {
       $result = call_user_func_array($function, $args);
       if (isset($result) && is_array($result)) {
@@ -825,15 +826,15 @@ function module_invoke_all($hook) {
 /**
  * Array of modules required by core.
  */
-function drupal_required_modules() {
-  $files = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info$/', 'modules', 'name', 0);
+function required_modules() {
+  $files = system_listing('/^' . PHP_FUNCTION_PATTERN . '\.info$/', 'modules', 'name', 0);
   $required = array();
 
   // An install profile is required and one must always be loaded.
-  $required[] = drupal_get_profile();
+  $required[] = get_profile();
 
   foreach ($files as $name => $file) {
-    $info = drupal_parse_info_file($file->uri);
+    $info = parse_info_file($file->uri);
     if (!empty($info) && !empty($info['required']) && $info['required']) {
       $required[] = $name;
     }
@@ -858,7 +859,7 @@ function drupal_required_modules() {
  *     'unalterable' => $unalterable,
  *     'foo' => 'bar',
  *   );
- *   drupal_alter('mymodule_data', $alterable1, $alterable2, $context);
+ *   alter('mymodule_data', $alterable1, $alterable2, $context);
  * @endcode
  *
  * Note that objects are always passed by reference in PHP5. If it is absolutely
@@ -868,7 +869,7 @@ function drupal_required_modules() {
  *   $context = array(
  *     'unalterable_object' => clone $object,
  *   );
- *   drupal_alter('mymodule_data', $data, $context);
+ *   alter('mymodule_data', $data, $context);
  * @endcode
  *
  * @param $type
@@ -876,7 +877,7 @@ function drupal_required_modules() {
  *   'node_content', and so on are several examples. Alternatively can be an
  *   array, in which case hook_TYPE_alter() is invoked for each value in the
  *   array, ordered first by module, and then for each module, in the order of
- *   values in $type. For example, when Form API is using drupal_alter() to
+ *   values in $type. For example, when Form API is using alter() to
  *   execute both hook_form_alter() and hook_form_FORM_ID_alter()
  *   implementations, it passes array('form', 'form_' . $form_id) for $type.
  * @param $data
@@ -891,13 +892,13 @@ function drupal_required_modules() {
  *   context needs to be provided to implementations, then this should be an
  *   associative array as described above.
  */
-function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) {
+function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) {
   // Use the advanced drupal_static() pattern, since this is called very often.
-  static $drupal_static_fast;
-  if (!isset($drupal_static_fast)) {
-    $drupal_static_fast['functions'] = &drupal_static(__FUNCTION__);
+  static $static_fast;
+  if (!isset($static_fast)) {
+    $static_fast['functions'] = &drupal_static(__FUNCTION__);
   }
-  $functions = &$drupal_static_fast['functions'];
+  $functions = &$static_fast['functions'];
 
   // Most of the time, $type is passed as a string, so for performance,
   // normalize it to that. When passed as an array, usually the first item in
@@ -930,7 +931,7 @@ function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) {
       // function_exists(), since module_implements() returns only modules with
       // implementations.
       foreach ($modules as $module) {
-        $functions[$cid][] = $module . '_' . $hook;
+        $functions[$cid][] = 'Drupal\\' . $module . '_' . $hook;
       }
     }
     else {
@@ -946,7 +947,7 @@ function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) {
       // implementations of a single hook. To get the ordered implementations
       // of multiple hooks, we mimic the module_implements() logic of first
       // ordering by module_list(), and then calling
-      // drupal_alter('module_implements').
+      // alter('module_implements').
       if (array_diff($extra_modules, $modules)) {
         // Merge the arrays and order by module_list().
         $modules = array_intersect(module_list(), array_merge($modules, $extra_modules));
@@ -955,22 +956,22 @@ function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) {
         $implementations = array_fill_keys($modules, FALSE);
         // Let modules adjust the order solely based on the primary hook. This
         // ensures the same module order regardless of whether this if block
-        // runs. Calling drupal_alter() recursively in this way does not result
+        // runs. Calling alter() recursively in this way does not result
         // in an infinite loop, because this call is for a single $type, so we
         // won't end up in this code block again.
-        drupal_alter('module_implements', $implementations, $hook);
+        alter('module_implements', $implementations, $hook);
         $modules = array_keys($implementations);
       }
       foreach ($modules as $module) {
         // Since $modules is a merged array, for any given module, we do not
         // know whether it has any particular implementation, so we need a
         // function_exists().
-        $function = $module . '_' . $hook;
+        $function = 'Drupal\\' . $module . '_' . $hook;
         if (function_exists($function)) {
           $functions[$cid][] = $function;
         }
         foreach ($extra_types as $extra_type) {
-          $function = $module . '_' . $extra_type . '_alter';
+          $function = 'Drupal\\' . $module . '_' . $extra_type . '_alter';
           if (function_exists($function)) {
             $functions[$cid][] = $function;
           }
@@ -987,13 +988,13 @@ function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) {
       }
       $theme_keys[] = $theme;
       foreach ($theme_keys as $theme_key) {
-        $function = $theme_key . '_' . $hook;
+        $function = 'Drupal\\' . $theme_key . '_' . $hook;
         if (function_exists($function)) {
           $functions[$cid][] = $function;
         }
         if (isset($extra_types)) {
           foreach ($extra_types as $extra_type) {
-            $function = $theme_key . '_' . $extra_type . '_alter';
+            $function = 'Drupal\\' . $theme_key . '_' . $extra_type . '_alter';
             if (function_exists($function)) {
               $functions[$cid][] = $function;
             }
diff --git a/core/includes/pager.inc b/core/includes/pager.inc
index a5d3e6b..9646159 100644
--- a/core/includes/pager.inc
+++ b/core/includes/pager.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -294,7 +295,7 @@ function pager_default_initialize($total, $limit, $element = 0) {
 function pager_get_query_parameters() {
   $query = &drupal_static(__FUNCTION__);
   if (!isset($query)) {
-    $query = drupal_get_query_parameters($_GET, array('q', 'page'));
+    $query = get_query_parameters($_GET, array('q', 'page'));
   }
   return $query;
 }
@@ -605,7 +606,7 @@ function theme_pager_link($variables) {
 
   $query = array();
   if (count($parameters)) {
-    $query = drupal_get_query_parameters($parameters, array());
+    $query = get_query_parameters($parameters, array());
   }
   if ($query_pager = pager_get_query_parameters()) {
     $query = array_merge($query, $query_pager);
diff --git a/core/includes/password.inc b/core/includes/password.inc
index b052a4a..c236fd7 100644
--- a/core/includes/password.inc
+++ b/core/includes/password.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -18,22 +19,22 @@
  * increase by 1 every Drupal version in order to counteract increases in the
  * speed and power of computers available to crack the hashes.
  */
-const DRUPAL_HASH_COUNT = 16;
+const HASH_COUNT = 16;
 
 /**
  * The minimum allowed log2 number of iterations for password stretching.
  */
-const DRUPAL_MIN_HASH_COUNT = 7;
+const MIN_HASH_COUNT = 7;
 
 /**
  * The maximum allowed log2 number of iterations for password stretching.
  */
-const DRUPAL_MAX_HASH_COUNT = 30;
+const MAX_HASH_COUNT = 30;
 
 /**
  * The expected (and maximum) number of characters in a hashed password.
  */
-const DRUPAL_HASH_LENGTH = 55;
+const HASH_LENGTH = 55;
 
 /**
  * Returns a string for mapping an int to the corresponding base 64 character.
@@ -104,7 +105,7 @@ function _password_generate_salt($count_log2) {
   $itoa64 = _password_itoa64();
   $output .= $itoa64[$count_log2];
   // 6 bytes is the standard salt for a portable phpass hash.
-  $output .= _password_base64_encode(drupal_random_bytes(6), 6);
+  $output .= _password_base64_encode(random_bytes(6), 6);
   return $output;
 }
 
@@ -119,11 +120,11 @@ function _password_generate_salt($count_log2) {
  *   Integer within set bounds that is closest to $count_log2.
  */
 function _password_enforce_log2_boundaries($count_log2) {
-  if ($count_log2 < DRUPAL_MIN_HASH_COUNT) {
-    return DRUPAL_MIN_HASH_COUNT;
+  if ($count_log2 < MIN_HASH_COUNT) {
+    return MIN_HASH_COUNT;
   }
-  elseif ($count_log2 > DRUPAL_MAX_HASH_COUNT) {
-    return DRUPAL_MAX_HASH_COUNT;
+  elseif ($count_log2 > MAX_HASH_COUNT) {
+    return MAX_HASH_COUNT;
   }
 
   return (int) $count_log2;
@@ -147,7 +148,7 @@ function _password_enforce_log2_boundaries($count_log2) {
  *
  * @return
  *   A string containing the hashed password (and salt) or FALSE on failure.
- *   The return string will be truncated at DRUPAL_HASH_LENGTH characters max.
+ *   The return string will be truncated at HASH_LENGTH characters max.
  */
 function _password_crypt($algo, $password, $setting) {
   // The first 12 characters of an existing hash are its setting string.
@@ -157,8 +158,8 @@ function _password_crypt($algo, $password, $setting) {
     return FALSE;
   }
   $count_log2 = _password_get_count_log2($setting);
-  // Hashes may be imported from elsewhere, so we allow != DRUPAL_HASH_COUNT
-  if ($count_log2 < DRUPAL_MIN_HASH_COUNT || $count_log2 > DRUPAL_MAX_HASH_COUNT) {
+  // Hashes may be imported from elsewhere, so we allow != HASH_COUNT
+  if ($count_log2 < MIN_HASH_COUNT || $count_log2 > MAX_HASH_COUNT) {
     return FALSE;
   }
   $salt = substr($setting, 4, 8);
@@ -181,7 +182,7 @@ function _password_crypt($algo, $password, $setting) {
   // _password_base64_encode() of a 16 byte MD5 will always be 22 characters.
   // _password_base64_encode() of a 64 byte sha512 will always be 86 characters.
   $expected = 12 + ceil((8 * $len) / 6);
-  return (strlen($output) == $expected) ? substr($output, 0, DRUPAL_HASH_LENGTH) : FALSE;
+  return (strlen($output) == $expected) ? substr($output, 0, HASH_LENGTH) : FALSE;
 }
 
 /**
@@ -207,7 +208,7 @@ function _password_get_count_log2($setting) {
 function user_hash_password($password, $count_log2 = 0) {
   if (empty($count_log2)) {
     // Use the standard iteration count.
-    $count_log2 = variable_get('password_count_log2', DRUPAL_HASH_COUNT);
+    $count_log2 = variable_get('password_count_log2', HASH_COUNT);
   }
   return _password_crypt('sha512', $password, _password_generate_salt($count_log2));
 }
@@ -264,7 +265,7 @@ function user_check_password($password, $account) {
  * This is typically called during the login process when the plain text
  * password is available. A new hash is needed when the desired iteration count
  * has changed through a change in the variable password_count_log2 or
- * DRUPAL_HASH_COUNT or if the user's password hash was generated in an update
+ * HASH_COUNT or if the user's password hash was generated in an update
  * like user_update_7000() (see the Drupal 7 documentation).
  *
  * Alternative implementations of this function might use other criteria based
@@ -278,11 +279,11 @@ function user_check_password($password, $account) {
  */
 function user_needs_new_hash($account) {
   // Check whether this was an updated password.
-  if ((substr($account->pass, 0, 3) != '$S$') || (strlen($account->pass) != DRUPAL_HASH_LENGTH)) {
+  if ((substr($account->pass, 0, 3) != '$S$') || (strlen($account->pass) != HASH_LENGTH)) {
     return TRUE;
   }
   // Ensure that $count_log2 is within set bounds.
-  $count_log2 = _password_enforce_log2_boundaries(variable_get('password_count_log2', DRUPAL_HASH_COUNT));
+  $count_log2 = _password_enforce_log2_boundaries(variable_get('password_count_log2', HASH_COUNT));
   // Check whether the iteration count used differs from the standard number.
   return (_password_get_count_log2($account->pass) !== $count_log2);
 }
diff --git a/core/includes/path.inc b/core/includes/path.inc
index 44bf3fe..d5afe00 100644
--- a/core/includes/path.inc
+++ b/core/includes/path.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use PDO;
 
 /**
  * @file
@@ -6,19 +8,19 @@
  *
  * These functions are not loaded for cached pages, but modules that need
  * to use them in hook_boot() or hook exit() can make them available, by
- * executing "drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);".
+ * executing "bootstrap(BOOTSTRAP_FULL);".
  */
 
 /**
  * Initialize the $_GET['q'] variable to the proper normal path.
  */
-function drupal_path_initialize() {
+function path_initialize() {
   // Ensure $_GET['q'] is set before calling drupal_normal_path(), to support
   // path caching with hook_url_inbound_alter().
   if (empty($_GET['q'])) {
     $_GET['q'] = variable_get('site_frontpage', 'user');
   }
-  $_GET['q'] = drupal_get_normal_path($_GET['q']);
+  $_GET['q'] = get_normal_path($_GET['q']);
 }
 
 /**
@@ -42,14 +44,14 @@ function drupal_path_initialize() {
  *   Either a Drupal system path, an aliased path, or FALSE if no path was
  *   found.
  */
-function drupal_lookup_path($action, $path = '', $langcode = NULL) {
+function lookup_path($action, $path = '', $langcode = NULL) {
   global $language_url;
   // Use the advanced drupal_static() pattern, since this is called very often.
-  static $drupal_static_fast;
-  if (!isset($drupal_static_fast)) {
-    $drupal_static_fast['cache'] = &drupal_static(__FUNCTION__);
+  static $static_fast;
+  if (!isset($static_fast)) {
+    $static_fast['cache'] = &drupal_static(__FUNCTION__);
   }
-  $cache = &$drupal_static_fast['cache'];
+  $cache = &$static_fast['cache'];
 
   if (!isset($cache)) {
     $cache = array(
@@ -66,7 +68,7 @@ function drupal_lookup_path($action, $path = '', $langcode = NULL) {
   if (!isset($cache['whitelist'])) {
     $cache['whitelist'] = variable_get('path_alias_whitelist', NULL);
     if (!isset($cache['whitelist'])) {
-      $cache['whitelist'] = drupal_path_alias_whitelist_rebuild();
+      $cache['whitelist'] = path_alias_whitelist_rebuild();
     }
   }
 
@@ -78,11 +80,11 @@ function drupal_lookup_path($action, $path = '', $langcode = NULL) {
 
   if ($action == 'wipe') {
     $cache = array();
-    $cache['whitelist'] = drupal_path_alias_whitelist_rebuild();
+    $cache['whitelist'] = path_alias_whitelist_rebuild();
   }
   elseif ($cache['whitelist'] && $path != '') {
     if ($action == 'alias') {
-      // During the first call to drupal_lookup_path() per language, load the
+      // During the first call to lookup_path() per language, load the
       // expected system paths for the page from cache.
       if (!empty($cache['first_call'])) {
         $cache['first_call'] = FALSE;
@@ -198,16 +200,16 @@ function drupal_lookup_path($action, $path = '', $langcode = NULL) {
  * Cache an array of the system paths available on each page. We assume
  * that aliases will be needed for the majority of these paths during
  * subsequent requests, and load them in a single query during
- * drupal_lookup_path().
+ * lookup_path().
  */
-function drupal_cache_system_paths() {
+function cache_system_paths() {
   // Check if the system paths for this page were loaded from cache in this
   // request to avoid writing to cache on every request.
-  $cache = &drupal_static('drupal_lookup_path', array());
+  $cache = &drupal_static('Drupal\lookup_path', array());
   if (empty($cache['system_paths']) && !empty($cache['map'])) {
     // Generate a cache ID (cid) specifically for this page.
     $cid = current_path();
-    // The static $map array used by drupal_lookup_path() includes all
+    // The static $map array used by lookup_path() includes all
     // system paths for the page request.
     if ($paths = current($cache['map'])) {
       $data = array_keys($paths);
@@ -232,13 +234,13 @@ function drupal_cache_system_paths() {
  *   An aliased path if one was found, or the original path if no alias was
  *   found.
  */
-function drupal_get_path_alias($path = NULL, $langcode = NULL) {
+function get_path_alias($path = NULL, $langcode = NULL) {
   // If no path is specified, use the current page's path.
   if ($path == NULL) {
     $path = $_GET['q'];
   }
   $result = $path;
-  if ($alias = drupal_lookup_path('alias', $path, $langcode)) {
+  if ($alias = lookup_path('alias', $path, $langcode)) {
     $result = $alias;
   }
   return $result;
@@ -256,19 +258,19 @@ function drupal_get_path_alias($path = NULL, $langcode = NULL) {
  *   The internal path represented by the alias, or the original alias if no
  *   internal path was found.
  */
-function drupal_get_normal_path($path, $langcode = NULL) {
+function get_normal_path($path, $langcode = NULL) {
   $original_path = $path;
 
   // Lookup the path alias first.
-  if ($source = drupal_lookup_path('source', $path, $langcode)) {
+  if ($source = lookup_path('source', $path, $langcode)) {
     $path = $source;
   }
 
-  // Allow other modules to alter the inbound URL. We cannot use drupal_alter()
+  // Allow other modules to alter the inbound URL. We cannot use alter()
   // here because we need to run hook_url_inbound_alter() in the reverse order
   // of hook_url_outbound_alter().
   foreach (array_reverse(module_implements('url_inbound_alter')) as $module) {
-    $function = $module . '_url_inbound_alter';
+    $function = 'Drupal\\' . $module . '_url_inbound_alter';
     $function($path, $original_path, $langcode);
   }
 
@@ -281,16 +283,16 @@ function drupal_get_normal_path($path, $langcode = NULL) {
  * @return
  *   Boolean value: TRUE if the current page is the front page; FALSE if otherwise.
  */
-function drupal_is_front_page() {
+function is_front_page() {
   // Use the advanced drupal_static() pattern, since this is called very often.
-  static $drupal_static_fast;
-  if (!isset($drupal_static_fast)) {
-    $drupal_static_fast['is_front_page'] = &drupal_static(__FUNCTION__);
+  static $static_fast;
+  if (!isset($static_fast)) {
+    $static_fast['is_front_page'] = &drupal_static(__FUNCTION__);
   }
-  $is_front_page = &$drupal_static_fast['is_front_page'];
+  $is_front_page = &$static_fast['is_front_page'];
 
   if (!isset($is_front_page)) {
-    // As drupal_path_initialize updates $_GET['q'] with the 'site_frontpage' path,
+    // As path_initialize updates $_GET['q'] with the 'site_frontpage' path,
     // we can check it against the 'site_frontpage' variable.
     $is_front_page = ($_GET['q'] == variable_get('site_frontpage', 'user'));
   }
@@ -309,7 +311,7 @@ function drupal_is_front_page() {
  * @return
  *   Boolean value: TRUE if the path matches a pattern, FALSE otherwise.
  */
-function drupal_match_path($path, $patterns) {
+function match_path($path, $patterns) {
   $regexps = &drupal_static(__FUNCTION__);
 
   if (!isset($regexps[$patterns])) {
@@ -344,7 +346,7 @@ function drupal_match_path($path, $patterns) {
  * This function is not available in hook_boot() so use $_GET['q'] instead.
  * However, be careful when doing that because in the case of Example #3
  * $_GET['q'] will contain "path/alias". If "node/306" is needed, calling
- * drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL) makes this function available.
+ * bootstrap(BOOTSTRAP_FULL) makes this function available.
  *
  * @return
  *   The current Drupal URL path.
@@ -364,7 +366,7 @@ function current_path() {
  * @return
  *   An array containing a white list of path aliases.
  */
-function drupal_path_alias_whitelist_rebuild($source = NULL) {
+function path_alias_whitelist_rebuild($source = NULL) {
   // When paths are inserted, only rebuild the whitelist if the system path
   // has a top level component which is not already in the whitelist.
   if (!empty($source)) {
@@ -434,7 +436,7 @@ function path_save(&$path) {
   $path += array('pid' => NULL, 'langcode' => LANGUAGE_NONE);
 
   // Insert or update the alias.
-  $status = drupal_write_record('url_alias', $path, (!empty($path['pid']) ? 'pid' : array()));
+  $status = write_record('url_alias', $path, (!empty($path['pid']) ? 'pid' : array()));
 
   // Verify that a record was written.
   if ($status) {
@@ -444,7 +446,7 @@ function path_save(&$path) {
     else {
       module_invoke_all('path_update', $path);
     }
-    drupal_clear_path_cache($path['source']);
+    clear_path_cache($path['source']);
   }
 }
 
@@ -465,7 +467,7 @@ function path_delete($criteria) {
   }
   $query->execute();
   module_invoke_all('path_delete', $path);
-  drupal_clear_path_cache($path['source']);
+  clear_path_cache($path['source']);
 }
 
 /**
@@ -490,8 +492,8 @@ function path_is_admin($path) {
   $path_map = &drupal_static(__FUNCTION__);
   if (!isset($path_map['admin'][$path])) {
     $patterns = path_get_admin_paths();
-    $path_map['admin'][$path] = drupal_match_path($path, $patterns['admin']);
-    $path_map['non_admin'][$path] = drupal_match_path($path, $patterns['non_admin']);
+    $path_map['admin'][$path] = match_path($path, $patterns['admin']);
+    $path_map['non_admin'][$path] = match_path($path, $patterns['non_admin']);
   }
   return $path_map['admin'][$path] && !$path_map['non_admin'][$path];
 }
@@ -502,7 +504,7 @@ function path_is_admin($path) {
  * @return array
  *   An associative array containing the following keys:
  *   'admin': An array of administrative paths and regular expressions
- *            in a format suitable for drupal_match_path().
+ *            in a format suitable for match_path().
  *   'non_admin': An array of non-administrative paths and regular expressions.
  *
  * @see hook_admin_paths()
@@ -512,7 +514,7 @@ function path_get_admin_paths() {
   $patterns = &drupal_static(__FUNCTION__);
   if (!isset($patterns)) {
     $paths = module_invoke_all('admin_paths');
-    drupal_alter('admin_paths', $paths);
+    alter('admin_paths', $paths);
     // Combine all admin paths into one array, and likewise for non-admin paths,
     // for easier handling.
     $patterns = array();
@@ -544,7 +546,7 @@ function path_get_admin_paths() {
  *   TRUE if it is a valid path AND the current user has access permission,
  *   FALSE otherwise.
  */
-function drupal_valid_path($path, $dynamic_allowed = FALSE) {
+function valid_path($path, $dynamic_allowed = FALSE) {
   global $menu_admin;
   // We indicate that a menu administrator is running the menu access check.
   $menu_admin = TRUE;
@@ -574,8 +576,8 @@ function drupal_valid_path($path, $dynamic_allowed = FALSE) {
  * @param $source
  *   An optional system path for which an alias is being changed.
  */
-function drupal_clear_path_cache($source = NULL) {
-  // Clear the drupal_lookup_path() static cache.
-  drupal_static_reset('drupal_lookup_path');
-  drupal_path_alias_whitelist_rebuild($source);
+function clear_path_cache($source = NULL) {
+  // Clear the lookup_path() static cache.
+  drupal_static_reset('Drupal\lookup_path');
+  path_alias_whitelist_rebuild($source);
 }
diff --git a/core/includes/registry.inc b/core/includes/registry.inc
index 2ddd1f7..233ce97 100644
--- a/core/includes/registry.inc
+++ b/core/includes/registry.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, PDO;
 
 /**
  * @file
@@ -29,9 +31,9 @@ function _registry_update() {
   // registry rebuild process runs.
   $connection_info = Database::getConnectionInfo();
   $driver = $connection_info['default']['driver'];
-  require_once DRUPAL_ROOT . '/core/includes/database/query.inc';
-  require_once DRUPAL_ROOT . '/core/includes/database/select.inc';
-  require_once DRUPAL_ROOT . '/core/includes/database/' . $driver . '/query.inc';
+  require_once ROOT . '/core/includes/database/query.inc';
+  require_once ROOT . '/core/includes/database/select.inc';
+  require_once ROOT . '/core/includes/database/' . $driver . '/query.inc';
 
   // Get current list of modules and their files.
   $modules = db_query("SELECT * FROM {system} WHERE type = 'module'")->fetchAll();
@@ -62,7 +64,7 @@ function _registry_update() {
     // includes the list of files registered to each module. Any files in the
     // list can then be added to the list of files that the registry will parse,
     // or modify attributes of a file.
-    drupal_alter('registry_files', $files, $modules);
+    alter('registry_files', $files, $modules);
     foreach (registry_get_parsed_files() as $filename => $file) {
       // Add the hash for those files we have already parsed.
       if (isset($files[$filename])) {
diff --git a/core/includes/session.inc b/core/includes/session.inc
index df70f0e..f3117d9 100644
--- a/core/includes/session.inc
+++ b/core/includes/session.inc
@@ -1,16 +1,18 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
  * User session handling functions.
  *
  * The user-level session storage handlers:
- * - _drupal_session_open()
- * - _drupal_session_close()
- * - _drupal_session_read()
- * - _drupal_session_write()
- * - _drupal_session_destroy()
- * - _drupal_session_garbage_collection()
+ * - _session_open()
+ * - _session_close()
+ * - _session_read()
+ * - _session_write()
+ * - _session_destroy()
+ * - _session_garbage_collection()
  * are assigned by session_set_save_handler() in bootstrap.inc and are called
  * automatically by PHP. These functions should not be called directly. Session
  * data should instead be accessed via the $_SESSION superglobal.
@@ -28,7 +30,7 @@
  * @return
  *   This function will always return TRUE.
  */
-function _drupal_session_open() {
+function _session_open() {
   return TRUE;
 }
 
@@ -44,7 +46,7 @@ function _drupal_session_open() {
  * @return
  *   This function will always return TRUE.
  */
-function _drupal_session_close() {
+function _session_close() {
   return TRUE;
 }
 
@@ -67,7 +69,7 @@ function _drupal_session_close() {
  * @return
  *   The user's session, or an empty string if no session exists.
  */
-function _drupal_session_read($sid) {
+function _session_read($sid) {
   global $user, $is_https;
 
   // Write and Close handlers are called after destructing objects
@@ -80,7 +82,7 @@ function _drupal_session_read($sid) {
   // cookies (eg. web crawlers).
   $insecure_session_name = substr(session_name(), 1);
   if (!isset($_COOKIE[session_name()]) && !isset($_COOKIE[$insecure_session_name])) {
-    $user = drupal_anonymous_user();
+    $user = anonymous_user();
     return '';
   }
 
@@ -110,24 +112,24 @@ function _drupal_session_read($sid) {
 
     // Add roles element to $user.
     $user->roles = array();
-    $user->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
+    $user->roles[AUTHENTICATED_RID] = 'authenticated user';
     $user->roles += db_query("SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = :uid", array(':uid' => $user->uid))->fetchAllKeyed(0, 1);
   }
   elseif ($user) {
     // The user is anonymous or blocked. Only preserve two fields from the
     // {sessions} table.
-    $account = drupal_anonymous_user();
+    $account = anonymous_user();
     $account->session = $user->session;
     $account->timestamp = $user->timestamp;
     $user = $account;
   }
   else {
     // The session has expired.
-    $user = drupal_anonymous_user();
+    $user = anonymous_user();
     $user->session = '';
   }
 
-  // Store the session that was read for comparison in _drupal_session_write().
+  // Store the session that was read for comparison in _session_write().
   $last_read = &drupal_static('drupal_session_last_read');
   $last_read = array(
     'sid' => $sid,
@@ -155,13 +157,13 @@ function _drupal_session_read($sid) {
  * @return
  *   Always returns TRUE.
  */
-function _drupal_session_write($sid, $value) {
+function _session_write($sid, $value) {
   global $user, $is_https;
 
   // The exception handler is not active at this point, so we need to do it
   // manually.
   try {
-    if (!drupal_save_session()) {
+    if (!save_session()) {
       // We don't have anything to do if we are not allowed to save the session.
       return;
     }
@@ -183,7 +185,7 @@ function _drupal_session_write($sid, $value) {
       );
 
       // Use the session ID as 'sid' and an empty string as 'ssid' by default.
-      // _drupal_session_read() does not allow empty strings so that's a safe
+      // _session_read() does not allow empty strings so that's a safe
       // default.
       $key = array('sid' => $sid, 'ssid' => '');
       // On HTTPS connections, use the session ID as both 'sid' and 'ssid'.
@@ -219,12 +221,12 @@ function _drupal_session_write($sid, $value) {
     return TRUE;
   }
   catch (Exception $exception) {
-    require_once DRUPAL_ROOT . '/core/includes/errors.inc';
+    require_once ROOT . '/core/includes/errors.inc';
     // If we are displaying errors, then do so with no possibility of a further
     // uncaught exception being thrown.
     if (error_displayable()) {
       print '<h1>Uncaught exception thrown in session handler.</h1>';
-      print '<p>' . _drupal_render_exception_safe($exception) . '</p><hr />';
+      print '<p>' . _render_exception_safe($exception) . '</p><hr />';
     }
     return FALSE;
   }
@@ -233,35 +235,35 @@ function _drupal_session_write($sid, $value) {
 /**
  * Initializes the session handler, starting a session if needed.
  */
-function drupal_session_initialize() {
+function session_initialize() {
   global $user, $is_https;
 
-  session_set_save_handler('_drupal_session_open', '_drupal_session_close', '_drupal_session_read', '_drupal_session_write', '_drupal_session_destroy', '_drupal_session_garbage_collection');
+  session_set_save_handler('Drupal\_session_open', 'Drupal\_session_close', 'Drupal\_session_read', 'Drupal\_session_write', 'Drupal\_session_destroy', 'Drupal\_session_garbage_collection');
 
   // We use !empty() in the following check to ensure that blank session IDs
   // are not valid.
   if (!empty($_COOKIE[session_name()]) || ($is_https && variable_get('https', FALSE) && !empty($_COOKIE[substr(session_name(), 1)]))) {
     // If a session cookie exists, initialize the session. Otherwise the
-    // session is only started on demand in drupal_session_commit(), making
+    // session is only started on demand in session_commit(), making
     // anonymous users not use a session cookie unless something is stored in
     // $_SESSION. This allows HTTP proxies to cache anonymous pageviews.
     drupal_session_start();
     if (!empty($user->uid) || !empty($_SESSION)) {
-      drupal_page_is_cacheable(FALSE);
+      page_is_cacheable(FALSE);
     }
   }
   else {
     // Set a session identifier for this request. This is necessary because
     // we lazily start sessions at the end of this request, and some
-    // processes (like drupal_get_token()) needs to know the future
+    // processes (like get_token()) needs to know the future
     // session ID in advance.
-    $user = drupal_anonymous_user();
+    $user = anonymous_user();
     // Less random sessions (which are much faster to generate) are used for
-    // anonymous users than are generated in drupal_session_regenerate() when
+    // anonymous users than are generated in session_regenerate() when
     // a user becomes authenticated.
-    session_id(drupal_hash_base64(uniqid(mt_rand(), TRUE)));
+    session_id(hash_base64(uniqid(mt_rand(), TRUE)));
   }
-  date_default_timezone_set(drupal_get_user_timezone());
+  date_default_timezone_set(get_user_timezone());
 }
 
 /**
@@ -271,12 +273,12 @@ function drupal_session_initialize() {
  */
 function drupal_session_start() {
   // Command line clients do not support cookies nor sessions.
-  if (!drupal_session_started() && !drupal_is_cli()) {
+  if (!session_started() && !is_cli()) {
     // Save current session data before starting it, as PHP will destroy it.
     $session_data = isset($_SESSION) ? $_SESSION : NULL;
 
     session_start();
-    drupal_session_started(TRUE);
+    session_started(TRUE);
 
     // Restore session data.
     if (!empty($session_data)) {
@@ -290,10 +292,10 @@ function drupal_session_start() {
  *
  * If an anonymous user already have an empty session, destroy it.
  */
-function drupal_session_commit() {
+function session_commit() {
   global $user;
 
-  if (!drupal_save_session()) {
+  if (!save_session()) {
     // We don't have anything to do if we are not allowed to save the session.
     return;
   }
@@ -301,14 +303,14 @@ function drupal_session_commit() {
   if (empty($user->uid) && empty($_SESSION)) {
     // There is no session data to store, destroy the session if it was
     // previously started.
-    if (drupal_session_started()) {
+    if (session_started()) {
       session_destroy();
     }
   }
   else {
     // There is session data to store. Start the session if it is not already
     // started.
-    if (!drupal_session_started()) {
+    if (!session_started()) {
       drupal_session_start();
     }
     // Write the session data.
@@ -319,7 +321,7 @@ function drupal_session_commit() {
 /**
  * Returns whether a session has been started.
  */
-function drupal_session_started($set = NULL) {
+function session_started($set = NULL) {
   static $session_started = FALSE;
   if (isset($set)) {
     $session_started = $set;
@@ -332,7 +334,7 @@ function drupal_session_started($set = NULL) {
  *
  * @ingroup php_wrappers
  */
-function drupal_session_regenerate() {
+function session_regenerate() {
   global $user, $is_https;
   if ($is_https && variable_get('https', FALSE)) {
     $insecure_session_name = substr(session_name(), 1);
@@ -340,7 +342,7 @@ function drupal_session_regenerate() {
       $old_insecure_session_id = $_COOKIE[$insecure_session_name];
     }
     $params = session_get_cookie_params();
-    $session_id = drupal_hash_base64(uniqid(mt_rand(), TRUE) . drupal_random_bytes(55));
+    $session_id = hash_base64(uniqid(mt_rand(), TRUE) . random_bytes(55));
     // If a session cookie lifetime is set, the session will expire
     // $params['lifetime'] seconds from the current request. If it is not set,
     // it will expire when the browser is closed.
@@ -349,10 +351,10 @@ function drupal_session_regenerate() {
     $_COOKIE[$insecure_session_name] = $session_id;
   }
 
-  if (drupal_session_started()) {
+  if (session_started()) {
     $old_session_id = session_id();
   }
-  session_id(drupal_hash_base64(uniqid(mt_rand(), TRUE) . drupal_random_bytes(55)));
+  session_id(hash_base64(uniqid(mt_rand(), TRUE) . random_bytes(55)));
 
   if (isset($old_session_id)) {
     $params = session_get_cookie_params();
@@ -384,12 +386,12 @@ function drupal_session_regenerate() {
   else {
     // Start the session when it doesn't exist yet.
     // Preserve the logged in user, as it will be reset to anonymous
-    // by _drupal_session_read.
+    // by _session_read.
     $account = $user;
     drupal_session_start();
     $user = $account;
   }
-  date_default_timezone_set(drupal_get_user_timezone());
+  date_default_timezone_set(get_user_timezone());
 }
 
 /**
@@ -400,7 +402,7 @@ function drupal_session_regenerate() {
  * @param $sid
  *   Session ID.
  */
-function _drupal_session_destroy($sid) {
+function _session_destroy($sid) {
   global $user, $is_https;
 
   // Delete session data.
@@ -409,14 +411,14 @@ function _drupal_session_destroy($sid) {
     ->execute();
 
   // Reset $_SESSION and $user to prevent a new session from being started
-  // in drupal_session_commit().
+  // in session_commit().
   $_SESSION = array();
-  $user = drupal_anonymous_user();
+  $user = anonymous_user();
 
   // Unset the session cookies.
-  _drupal_session_delete_cookie(session_name());
+  _session_delete_cookie(session_name());
   if ($is_https) {
-    _drupal_session_delete_cookie(substr(session_name(), 1), TRUE);
+    _session_delete_cookie(substr(session_name(), 1), TRUE);
   }
 }
 
@@ -428,7 +430,7 @@ function _drupal_session_destroy($sid) {
  * @param $force_insecure
  *   Force cookie to be insecure.
  */
-function _drupal_session_delete_cookie($name, $force_insecure = FALSE) {
+function _session_delete_cookie($name, $force_insecure = FALSE) {
   if (isset($_COOKIE[$name])) {
     $params = session_get_cookie_params();
     setcookie($name, '', REQUEST_TIME - 3600, $params['path'], $params['domain'], !$force_insecure && $params['secure'], $params['httponly']);
@@ -442,7 +444,7 @@ function _drupal_session_delete_cookie($name, $force_insecure = FALSE) {
  * @param $uid
  *   User ID.
  */
-function drupal_session_destroy_uid($uid) {
+function session_destroy_uid($uid) {
   db_delete('sessions')
     ->condition('uid', $uid)
     ->execute();
@@ -457,7 +459,7 @@ function drupal_session_destroy_uid($uid) {
  *   The value of session.gc_maxlifetime, passed by PHP.
  *   Sessions not updated for more than $lifetime seconds will be removed.
  */
-function _drupal_session_garbage_collection($lifetime) {
+function _session_garbage_collection($lifetime) {
   // Be sure to adjust 'php_value session.gc_maxlifetime' to a large enough
   // value. For example, if you want user sessions to stay in your database
   // for three weeks before deleting them, you need to set gc_maxlifetime
@@ -484,7 +486,7 @@ function _drupal_session_garbage_collection($lifetime) {
  * @return
  *   FALSE if writing session data has been disabled. Otherwise, TRUE.
  */
-function drupal_save_session($status = NULL) {
+function save_session($status = NULL) {
   $save_session = &drupal_static(__FUNCTION__, TRUE);
   if (isset($status)) {
     $save_session = $status;
diff --git a/core/includes/standard.inc b/core/includes/standard.inc
index 808073f..2a96208 100644
--- a/core/includes/standard.inc
+++ b/core/includes/standard.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/includes/stream_wrappers.inc b/core/includes/stream_wrappers.inc
index 0edcee1..bf774fe 100644
--- a/core/includes/stream_wrappers.inc
+++ b/core/includes/stream_wrappers.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -228,10 +229,10 @@ interface DrupalStreamWrapperInterface extends StreamWrapperInterface {
  * "sites/default/files/example.txt" and then PHP filesystem functions are
  * invoked.
  *
- * DrupalLocalStreamWrapper implementations need to implement at least the
+ * LocalStreamWrapper implementations need to implement at least the
  * getDirectoryPath() and getExternalUrl() methods.
  */
-abstract class DrupalLocalStreamWrapper implements DrupalStreamWrapperInterface {
+abstract class LocalStreamWrapper implements DrupalStreamWrapperInterface {
   /**
    * Stream context resource.
    *
@@ -312,12 +313,12 @@ abstract class DrupalLocalStreamWrapper implements DrupalStreamWrapperInterface
     if (!isset($mapping)) {
       // The default file map, defined in file.mimetypes.inc is quite big.
       // We only load it when necessary.
-      include_once DRUPAL_ROOT . '/core/includes/file.mimetypes.inc';
+      include_once ROOT . '/core/includes/file.mimetypes.inc';
       $mapping = file_mimetype_mapping();
     }
 
     $extension = '';
-    $file_parts = explode('.', drupal_basename($uri));
+    $file_parts = explode('.', basename($uri));
 
     // Remove the first part: a full filename should not match an extension.
     array_shift($file_parts);
@@ -364,7 +365,7 @@ abstract class DrupalLocalStreamWrapper implements DrupalStreamWrapperInterface
    *
    * @return string|false
    *   If $uri is not set, returns the canonical absolute path of the URI
-   *   previously set by the DrupalStreamWrapperInterface::setUri() function.
+   *   previously set by the StreamWrapperInterface::setUri() function.
    *   If $uri is set and valid for this class, returns its canonical absolute
    *   path, as determined by the realpath() function. If $uri is set but not
    *   valid, returns FALSE.
@@ -377,7 +378,7 @@ abstract class DrupalLocalStreamWrapper implements DrupalStreamWrapperInterface
     $realpath = realpath($path);
     if (!$realpath) {
       // This file does not yet exist.
-      $realpath = realpath(dirname($path)) . '/' . drupal_basename($path);
+      $realpath = realpath(dirname($path)) . '/' . basename($path);
     }
     $directory = realpath($this->getDirectoryPath());
     if (!$realpath || !$directory || strpos($realpath, $directory) !== 0) {
@@ -763,7 +764,7 @@ abstract class DrupalLocalStreamWrapper implements DrupalStreamWrapperInterface
  * Provides support for storing publicly accessible files with the Drupal file
  * interface.
  */
-class DrupalPublicStreamWrapper extends DrupalLocalStreamWrapper {
+class PublicStreamWrapper extends LocalStreamWrapper {
   /**
    * Implements abstract public function getDirectoryPath()
    */
@@ -778,7 +779,7 @@ class DrupalPublicStreamWrapper extends DrupalLocalStreamWrapper {
    */
   function getExternalUrl() {
     $path = str_replace('\\', '/', $this->getTarget());
-    return $GLOBALS['base_url'] . '/' . self::getDirectoryPath() . '/' . drupal_encode_path($path);
+    return $GLOBALS['base_url'] . '/' . self::getDirectoryPath() . '/' . encode_path($path);
   }
 }
 
@@ -789,9 +790,9 @@ class DrupalPublicStreamWrapper extends DrupalLocalStreamWrapper {
  * Provides support for storing privately accessible files with the Drupal file
  * interface.
  *
- * Extends DrupalPublicStreamWrapper.
+ * Extends PublicStreamWrapper.
  */
-class DrupalPrivateStreamWrapper extends DrupalLocalStreamWrapper {
+class PrivateStreamWrapper extends LocalStreamWrapper {
   /**
    * Implements abstract public function getDirectoryPath()
    */
@@ -816,9 +817,9 @@ class DrupalPrivateStreamWrapper extends DrupalLocalStreamWrapper {
  * Provides support for storing temporarily accessible files with the Drupal
  * file interface.
  *
- * Extends DrupalPublicStreamWrapper.
+ * Extends PublicStreamWrapper.
  */
-class DrupalTemporaryStreamWrapper extends DrupalLocalStreamWrapper {
+class TemporaryStreamWrapper extends LocalStreamWrapper {
   /**
    * Implements abstract public function getDirectoryPath()
    */
diff --git a/core/includes/tablesort.inc b/core/includes/tablesort.inc
index 7873cdb..00a5993 100644
--- a/core/includes/tablesort.inc
+++ b/core/includes/tablesort.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -190,7 +191,7 @@ function tablesort_cell($cell, $header, $ts, $i) {
  *   page request except for those pertaining to table sorting.
  */
 function tablesort_get_query_parameters() {
-  return drupal_get_query_parameters($_GET, array('q', 'sort', 'order'));
+  return get_query_parameters($_GET, array('q', 'sort', 'order'));
 }
 
 /**
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 0c955e8..2308dfd 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -44,22 +46,22 @@ const MARK_UPDATED = 2;
  *   Boolean TRUE if the theme is enabled or is the site administration theme;
  *   FALSE otherwise.
  */
-function drupal_theme_access($theme) {
+function theme_access($theme) {
   if (is_object($theme)) {
-    return _drupal_theme_access($theme);
+    return _theme_access($theme);
   }
   else {
     $themes = list_themes();
-    return isset($themes[$theme]) && _drupal_theme_access($themes[$theme]);
+    return isset($themes[$theme]) && _theme_access($themes[$theme]);
   }
 }
 
 /**
  * Helper function for determining access to a theme.
  *
- * @see drupal_theme_access()
+ * @see theme_access()
  */
-function _drupal_theme_access($theme) {
+function _theme_access($theme) {
   $admin_theme = variable_get('admin_theme');
   return !empty($theme->status) || ($admin_theme && $theme->name == $admin_theme);
 }
@@ -67,7 +69,7 @@ function _drupal_theme_access($theme) {
 /**
  * Initialize the theme system by loading the theme.
  */
-function drupal_theme_initialize() {
+function theme_initialize() {
   global $theme, $user, $theme_key;
 
   // If $theme is already set, assume the others are set, too, and do nothing
@@ -75,12 +77,12 @@ function drupal_theme_initialize() {
     return;
   }
 
-  drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
+  bootstrap(BOOTSTRAP_DATABASE);
   $themes = list_themes();
 
   // Only select the user selected theme if it is available in the
   // list of themes that can be accessed.
-  $theme = !empty($user->theme) && drupal_theme_access($user->theme) ? $user->theme : variable_get('theme_default', 'stark');
+  $theme = !empty($user->theme) && theme_access($user->theme) ? $user->theme : variable_get('theme_default', 'stark');
 
   // Allow modules to override the theme. Validation has already been performed
   // inside menu_get_custom_theme(), so we do not need to check it again here.
@@ -97,19 +99,19 @@ function drupal_theme_initialize() {
     $ancestor = $themes[$ancestor]->base_theme;
     $base_theme[] = $themes[$ancestor];
   }
-  _drupal_theme_initialize($themes[$theme], array_reverse($base_theme));
+  _theme_initialize($themes[$theme], array_reverse($base_theme));
 
-  // Themes can have alter functions, so reset the drupal_alter() cache.
-  drupal_static_reset('drupal_alter');
+  // Themes can have alter functions, so reset the alter() cache.
+  drupal_static_reset('Drupal\alter');
 
   // Provide the page with information about the theme that's used, so that a
   // later Ajax request can be rendered using the same theme.
   // @see ajax_base_page_theme()
   $setting['ajaxPageState'] = array(
     'theme' => $theme_key,
-    'theme_token' => drupal_get_token($theme_key),
+    'theme_token' => get_token($theme_key),
   );
-  drupal_add_js($setting, 'setting');
+  add_js($setting, 'setting');
 }
 
 /**
@@ -137,7 +139,7 @@ function drupal_theme_initialize() {
  * @param $registry_callback
  *   The callback to invoke to set the theme registry.
  */
-function _drupal_theme_initialize($theme, $base_theme = array(), $registry_callback = '_theme_load_registry') {
+function _theme_initialize($theme, $base_theme = array(), $registry_callback = '_theme_load_registry') {
   global $theme_info, $base_theme_info, $theme_engine, $theme_path;
   $theme_info = $theme;
   $base_theme_info = $base_theme;
@@ -172,7 +174,7 @@ function _drupal_theme_initialize($theme, $base_theme = array(), $registry_callb
   // And now add the stylesheets properly
   foreach ($final_stylesheets as $media => $stylesheets) {
     foreach ($stylesheets as $stylesheet) {
-      drupal_add_css($stylesheet, array('group' => CSS_THEME, 'every_page' => TRUE, 'media' => $media));
+      add_css($stylesheet, array('group' => CSS_THEME, 'every_page' => TRUE, 'media' => $media));
     }
   }
 
@@ -197,7 +199,7 @@ function _drupal_theme_initialize($theme, $base_theme = array(), $registry_callb
 
   // Add scripts used by this theme.
   foreach ($final_scripts as $script) {
-    drupal_add_js($script, array('group' => JS_THEME, 'every_page' => TRUE));
+    add_js($script, array('group' => JS_THEME, 'every_page' => TRUE));
   }
 
   $theme_engine = NULL;
@@ -205,14 +207,14 @@ function _drupal_theme_initialize($theme, $base_theme = array(), $registry_callb
   // Initialize the theme.
   if (isset($theme->engine)) {
     // Include the engine.
-    include_once DRUPAL_ROOT . '/' . $theme->owner;
-
+    include_once ROOT . '/' . $theme->owner;
     $theme_engine = $theme->engine;
-    if (function_exists($theme_engine . '_init')) {
+    $function = 'Drupal\\' . $theme_engine . '_init';
+    if (function_exists($function)) {
       foreach ($base_theme as $base) {
-        call_user_func($theme_engine . '_init', $base);
+        call_user_func($function, $base);
       }
-      call_user_func($theme_engine . '_init', $theme);
+      call_user_func($function, $theme);
     }
   }
   else {
@@ -220,12 +222,12 @@ function _drupal_theme_initialize($theme, $base_theme = array(), $registry_callb
     foreach ($base_theme as $base) {
       // Include the theme file or the engine.
       if (!empty($base->owner)) {
-        include_once DRUPAL_ROOT . '/' . $base->owner;
+        include_once ROOT . '/' . $base->owner;
       }
     }
     // and our theme gets one too.
     if (!empty($theme->owner)) {
-      include_once DRUPAL_ROOT . '/' . $theme->owner;
+      include_once ROOT . '/' . $theme->owner;
     }
   }
 
@@ -260,7 +262,7 @@ function theme_get_registry($complete = TRUE) {
     if (!$complete) {
       $arguments[] = FALSE;
     }
-    $theme_registry[$key] = call_user_func_array($callback, $arguments);
+    $theme_registry[$key] = call_user_func_array('Drupal\\' . $callback, $arguments);
   }
 
   return $theme_registry[$key];
@@ -334,19 +336,19 @@ function _theme_save_registry($theme, $registry) {
  * when modules are added to the system, or when a dynamic system needs
  * to add more theme hooks.
  */
-function drupal_theme_rebuild() {
+function theme_rebuild() {
   cache()->deletePrefix('theme_registry');
 }
 
 /**
  * Builds the run-time theme registry.
  *
- * Extends DrupalCacheArray to allow the theme registry to be accessed as a
+ * Extends CacheArray to allow the theme registry to be accessed as a
  * complete registry, while internally caching only the parts of the registry
  * that are actually in use on the site. On cache misses the complete
  * theme registry is loaded and used to update the run-time cache.
  */
-class ThemeRegistry Extends DrupalCacheArray {
+class ThemeRegistry Extends CacheArray {
 
   /**
    * Whether the partial registry can be persisted to the cache.
@@ -515,7 +517,7 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) {
 
   // Invoke the hook_theme() implementation, process what is returned, and
   // merge it into $cache.
-  $function = $name . '_theme';
+  $function = 'Drupal\\' . $name . '_theme';
   if (function_exists($function)) {
     $result = $function($cache, $type, $theme, $path);
     foreach ($result as $hook => $info) {
@@ -546,7 +548,7 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) {
       if (isset($info['file'])) {
         $include_file = isset($info['path']) ? $info['path'] : $path;
         $include_file .= '/' . $info['file'];
-        include_once DRUPAL_ROOT . '/' . $include_file;
+        include_once ROOT . '/' . $include_file;
         $result[$hook]['includes'][] = $include_file;
       }
 
@@ -595,10 +597,10 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) {
           foreach ($prefixes as $prefix) {
             // Only use non-hook-specific variable processors for theming hooks
             // implemented as templates. See theme().
-            if (isset($info['template']) && function_exists($prefix . '_' . $phase)) {
+            if (isset($info['template']) && function_exists('Drupal\\' . $prefix . '_' . $phase)) {
               $info[$phase_key][] = $prefix . '_' . $phase;
             }
-            if (function_exists($prefix . '_' . $phase . '_' . $hook)) {
+            if (function_exists('Drupal\\' . $prefix . '_' . $phase . '_' . $hook)) {
               $info[$phase_key][] = $prefix . '_' . $phase . '_' . $hook;
             }
           }
@@ -632,10 +634,10 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) {
           }
           // Only use non-hook-specific variable processors for theming hooks
           // implemented as templates. See theme().
-          if (isset($info['template']) && function_exists($name . '_' . $phase)) {
+          if (isset($info['template']) && function_exists('Drupal\\' . $name . '_' . $phase)) {
             $cache[$hook][$phase_key][] = $name . '_' . $phase;
           }
-          if (function_exists($name . '_' . $phase . '_' . $hook)) {
+          if (function_exists('Drupal\\' . $name . '_' . $phase . '_' . $hook)) {
             $cache[$hook][$phase_key][] = $name . '_' . $phase . '_' . $hook;
             $cache[$hook]['theme path'] = $path;
           }
@@ -669,7 +671,7 @@ function _theme_build_registry($theme, $base_theme, $theme_engine) {
   }
   else {
     foreach (module_implements('theme') as $module) {
-      _theme_process_registry($cache, $module, 'module', $module, drupal_get_path('module', $module));
+      _theme_process_registry($cache, $module, 'module', $module, get_path('module', $module));
     }
     // Only cache this registry if all modules are loaded.
     if (module_load_all(NULL)) {
@@ -696,7 +698,7 @@ function _theme_build_registry($theme, $base_theme, $theme_engine) {
   _theme_process_registry($cache, $theme->name, 'theme', $theme->name, dirname($theme->filename));
 
   // Let modules alter the registry.
-  drupal_alter('theme_registry', $cache);
+  alter('theme_registry', $cache);
 
   // Optimize the registry to not have empty arrays for functions.
   foreach ($cache as $hook => $info) {
@@ -909,7 +911,7 @@ function theme($hook, $variables = array()) {
   }
 
   if (!isset($hooks)) {
-    drupal_theme_initialize();
+    theme_initialize();
     $hooks = theme_get_registry(FALSE);
   }
 
@@ -954,7 +956,7 @@ function theme($hook, $variables = array()) {
   // Include a file if the theme function or variable processor is held elsewhere.
   if (!empty($info['includes'])) {
     foreach ($info['includes'] as $include_file) {
-      include_once DRUPAL_ROOT . '/' . $include_file;
+      include_once ROOT . '/' . $include_file;
     }
   }
 
@@ -1002,6 +1004,7 @@ function theme($hook, $variables = array()) {
     foreach (array('preprocess functions', 'process functions') as $phase) {
       if (!empty($info[$phase])) {
         foreach ($info[$phase] as $processor_function) {
+          $processor_function = 'Drupal\\' . $processor_function;
           if (function_exists($processor_function)) {
             // We don't want a poorly behaved process function changing $hook.
             $hook_clone = $hook;
@@ -1040,23 +1043,24 @@ function theme($hook, $variables = array()) {
   // Generate the output using either a function or a template.
   $output = '';
   if (isset($info['function'])) {
-    if (function_exists($info['function'])) {
-      $output = $info['function']($variables);
+    $function = 'Drupal\\' . $info['function'];
+    if (function_exists($function)) {
+      $output = $function($variables);
     }
   }
   else {
     // Default render function and extension.
-    $render_function = 'theme_render_template';
+    $render_function = 'Drupal\theme_render_template';
     $extension = '.tpl.php';
 
     // The theme engine may use a different extension and a different renderer.
     global $theme_engine;
     if (isset($theme_engine)) {
       if ($info['type'] != 'module') {
-        if (function_exists($theme_engine . '_render_template')) {
-          $render_function = $theme_engine . '_render_template';
+        if (function_exists('Drupal\\' . $theme_engine . '_render_template')) {
+          $render_function = 'Drupal\\' . $theme_engine . '_render_template';
         }
-        $extension_function = $theme_engine . '_extension';
+        $extension_function = 'Drupal\\' . $theme_engine . '_extension';
         if (function_exists($extension_function)) {
           $extension = $extension_function();
         }
@@ -1106,7 +1110,7 @@ function path_to_theme() {
   global $theme_path;
 
   if (!isset($theme_path)) {
-    drupal_theme_initialize();
+    theme_initialize();
   }
 
   return $theme_path;
@@ -1123,7 +1127,7 @@ function path_to_theme() {
  * @return $implementations
  *   The functions found, suitable for returning from hook_theme;
  */
-function drupal_find_theme_functions($cache, $prefixes) {
+function find_theme_functions($cache, $prefixes) {
   $implementations = array();
   $functions = get_defined_functions();
 
@@ -1142,13 +1146,14 @@ function drupal_find_theme_functions($cache, $prefixes) {
       // intermediary suggestion.
       $pattern = isset($info['pattern']) ? $info['pattern'] : ($hook . '__');
       if (!isset($info['base hook']) && !empty($pattern)) {
-        $matches = preg_grep('/^' . $prefix . '_' . $pattern . '/', $functions['user']);
+        // Namespaces from get_defined_functions() are lowercase.
+        $matches = preg_grep('/^drupal\\\\' . $prefix . '_' . $pattern . '/', $functions['user']);
         if ($matches) {
           foreach ($matches as $match) {
-            $new_hook = substr($match, strlen($prefix) + 1);
+            $new_hook = substr($match, strlen($prefix) + 8);
             $arg_name = isset($info['variables']) ? 'variables' : 'render element';
             $implementations[$new_hook] = array(
-              'function' => $match,
+              'function' => $prefix . '_' . $new_hook,
               $arg_name => $info[$arg_name],
               'base hook' => $hook,
             );
@@ -1158,7 +1163,7 @@ function drupal_find_theme_functions($cache, $prefixes) {
       // Find theme functions that implement registered theme hooks and include
       // that in what is returned so that the registry knows that the theme has
       // this implementation.
-      if (function_exists($prefix . '_' . $hook)) {
+      if (function_exists('Drupal\\' . $prefix . '_' . $hook)) {
         $implementations[$hook] = array(
           'function' => $prefix . '_' . $hook,
         );
@@ -1179,7 +1184,7 @@ function drupal_find_theme_functions($cache, $prefixes) {
  * @param $path
  *   The path to search.
  */
-function drupal_find_theme_templates($cache, $extension, $path) {
+function find_theme_templates($cache, $extension, $path) {
   $implementations = array();
 
   // Collect paths to all sub-themes grouped by base themes. These will be
@@ -1246,7 +1251,7 @@ function drupal_find_theme_templates($cache, $extension, $path) {
 
   // Find templates that implement possible "suggestion" variants of registered
   // theme hooks and add those as new registered theme hooks. See
-  // drupal_find_theme_functions() for more information about suggestions and
+  // find_theme_functions() for more information about suggestions and
   // the use of 'pattern' and 'base hook'.
   $patterns = array_keys($files);
   foreach ($cache as $hook => $info) {
@@ -1407,7 +1412,7 @@ function theme_get_setting($setting_name, $theme = NULL) {
 function theme_render_template($template_file, $variables) {
   extract($variables, EXTR_SKIP);               // Extract the variables to a local namespace
   ob_start();                                   // Start output buffering
-  include DRUPAL_ROOT . '/' . $template_file;   // Include the template file
+  include ROOT . '/' . $template_file;   // Include the template file
   return ob_get_clean();                        // End buffering and return its contents
 }
 
@@ -1418,7 +1423,7 @@ function theme_render_template($template_file, $variables) {
  *   An array of theme names.
  */
 function theme_enable($theme_list) {
-  drupal_clear_css_cache();
+  clear_css_cache();
 
   foreach ($theme_list as $key) {
     db_update('system')
@@ -1430,7 +1435,7 @@ function theme_enable($theme_list) {
 
   list_themes(TRUE);
   menu_rebuild();
-  drupal_theme_rebuild();
+  theme_rebuild();
 
   // Invoke hook_themes_enabled() after the themes have been enabled.
   module_invoke_all('themes_enabled', $theme_list);
@@ -1451,7 +1456,7 @@ function theme_disable($theme_list) {
     }
   }
 
-  drupal_clear_css_cache();
+  clear_css_cache();
 
   foreach ($theme_list as $key) {
     db_update('system')
@@ -1463,7 +1468,7 @@ function theme_disable($theme_list) {
 
   list_themes(TRUE);
   menu_rebuild();
-  drupal_theme_rebuild();
+  theme_rebuild();
 
   // Invoke hook_themes_disabled after the themes have been disabled.
   module_invoke_all('themes_disabled', $theme_list);
@@ -1495,7 +1500,7 @@ function theme_status_messages($variables) {
     'error' => t('Error message'),
     'warning' => t('Warning message'),
   );
-  foreach (drupal_get_messages($display) as $type => $messages) {
+  foreach (get_messages($display) as $type => $messages) {
     $output .= "<div class=\"messages $type\">\n";
     if (!empty($status_heading[$type])) {
       $output .= '<h2 class="element-invisible">' . $status_heading[$type] . "</h2>\n";
@@ -1534,7 +1539,7 @@ function theme_status_messages($variables) {
  * @see l()
  */
 function theme_link($variables) {
-  return '<a href="' . check_plain(url($variables['path'], $variables['options'])) . '"' . drupal_attributes($variables['options']['attributes']) . '>' . ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text'])) . '</a>';
+  return '<a href="' . check_plain(url($variables['path'], $variables['options'])) . '"' . attributes($variables['options']['attributes']) . '>' . ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text'])) . '</a>';
 }
 
 /**
@@ -1597,12 +1602,12 @@ function theme_links($variables) {
         $heading['attributes']['class'] = $heading['class'];
       }
 
-      $output .= '<' . $heading['level'] . drupal_attributes($heading['attributes']) . '>';
+      $output .= '<' . $heading['level'] . attributes($heading['attributes']) . '>';
       $output .= check_plain($heading['text']);
       $output .= '</' . $heading['level'] . '>';
     }
 
-    $output .= '<ul' . drupal_attributes($attributes) . '>';
+    $output .= '<ul' . attributes($attributes) . '>';
 
     $num_links = count($links);
     $i = 0;
@@ -1611,7 +1616,7 @@ function theme_links($variables) {
 
       $class = array();
       // Use the array key as class name.
-      $class[] = drupal_html_class($key);
+      $class[] = html_class($key);
       // Add odd/even, first, and last classes.
       $class[] = ($i % 2 ? 'odd' : 'even');
       if ($i == 1) {
@@ -1623,7 +1628,7 @@ function theme_links($variables) {
 
       // Handle links.
       if (isset($link['href'])) {
-        $is_current_path = ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()));
+        $is_current_path = ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && is_front_page()));
         $is_current_language = (empty($link['language']) || $link['language']->langcode == $language_url->langcode);
         if ($is_current_path && $is_current_language) {
           $class[] = 'active';
@@ -1638,12 +1643,12 @@ function theme_links($variables) {
           'html' => FALSE,
           'attributes' => array(),
         );
-        $item = '<span' . drupal_attributes($link['attributes']) . '>';
+        $item = '<span' . attributes($link['attributes']) . '>';
         $item .= ($link['html'] ? $link['title'] : check_plain($link['title']));
         $item .= '</span>';
       }
 
-      $output .= '<li' . drupal_attributes(array('class' => $class)) . '>';
+      $output .= '<li' . attributes(array('class' => $class)) . '>';
       $output .= $item;
       $output .= '</li>';
     }
@@ -1687,7 +1692,7 @@ function theme_image($variables) {
     }
   }
 
-  return '<img' . drupal_attributes($attributes) . ' />';
+  return '<img' . attributes($attributes) . ' />';
 }
 
 /**
@@ -1797,13 +1802,13 @@ function theme_table($variables) {
 
   // Add sticky headers, if applicable.
   if (count($header) && $sticky) {
-    drupal_add_js('core/misc/tableheader.js');
+    add_js('core/misc/tableheader.js');
     // Add 'sticky-enabled' class to the table to identify it for JS.
     // This is needed to target tables constructed by this function.
     $attributes['class'][] = 'sticky-enabled';
   }
 
-  $output = '<table' . drupal_attributes($attributes) . ">\n";
+  $output = '<table' . attributes($attributes) . ">\n";
 
   if (isset($caption)) {
     $output .= '<caption>' . $caption . "</caption>\n";
@@ -1831,15 +1836,15 @@ function theme_table($variables) {
 
       // Build colgroup
       if (is_array($cols) && count($cols)) {
-        $output .= ' <colgroup' . drupal_attributes($attributes) . '>';
+        $output .= ' <colgroup' . attributes($attributes) . '>';
         $i = 0;
         foreach ($cols as $col) {
-          $output .= ' <col' . drupal_attributes($col) . ' />';
+          $output .= ' <col' . attributes($col) . ' />';
         }
         $output .= " </colgroup>\n";
       }
       else {
-        $output .= ' <colgroup' . drupal_attributes($attributes) . " />\n";
+        $output .= ' <colgroup' . attributes($attributes) . " />\n";
       }
     }
   }
@@ -1905,7 +1910,7 @@ function theme_table($variables) {
         }
 
         // Build row
-        $output .= ' <tr' . drupal_attributes($attributes) . '>';
+        $output .= ' <tr' . attributes($attributes) . '>';
         $i = 0;
         foreach ($cells as $cell) {
           $cell = tablesort_cell($cell, $header, $ts, $i++);
@@ -1983,7 +1988,7 @@ function theme_item_list($variables) {
 
   $output = '';
   if ($items) {
-    $output .= '<' . $type . drupal_attributes($list_attributes) . '>';
+    $output .= '<' . $type . attributes($list_attributes) . '>';
 
     $num_items = count($items);
     $i = 0;
@@ -2029,7 +2034,7 @@ function theme_item_list($variables) {
         $attributes['class'][] = 'last';
       }
 
-      $output .= '<li' . drupal_attributes($attributes) . '>' . $value . '</li>';
+      $output .= '<li' . attributes($attributes) . '>' . $value . '</li>';
     }
     $output .= "</$type>";
   }
@@ -2092,7 +2097,7 @@ function theme_feed_icon($variables) {
  */
 function theme_html_tag($variables) {
   $element = $variables['element'];
-  $attributes = isset($element['#attributes']) ? drupal_attributes($element['#attributes']) : '';
+  $attributes = isset($element['#attributes']) ? attributes($element['#attributes']) : '';
   if (!isset($element['#value'])) {
     return '<' . $element['#tag'] . $attributes . " />\n";
   }
@@ -2186,7 +2191,7 @@ function _theme_table_cell($cell, $header = FALSE) {
     $header |= isset($cell['header']);
     unset($cell['data']);
     unset($cell['header']);
-    $attributes = drupal_attributes($cell);
+    $attributes = attributes($cell);
   }
   else {
     $data = $cell;
@@ -2224,16 +2229,16 @@ function template_preprocess(&$variables, $hook) {
   $variables['directory'] = path_to_theme();
 
   // Initialize html class attribute for the current hook.
-  $variables['classes_array'] = array(drupal_html_class($hook));
+  $variables['classes_array'] = array(html_class($hook));
 
   // Merge in variables that don't depend on hook and don't change during a
   // single page request.
   // Use the advanced drupal_static() pattern, since this is called very often.
-  static $drupal_static_fast;
-  if (!isset($drupal_static_fast)) {
-    $drupal_static_fast['default_variables'] = &drupal_static(__FUNCTION__);
+  static $static_fast;
+  if (!isset($static_fast)) {
+    $static_fast['default_variables'] = &drupal_static(__FUNCTION__);
   }
-  $default_variables = &$drupal_static_fast['default_variables'];
+  $default_variables = &$static_fast['default_variables'];
   // Global $user object shouldn't change during a page request once rendering
   // has started, but if there's an edge case where it does, re-fetch the
   // variables appropriate for the new user.
@@ -2265,14 +2270,14 @@ function _template_preprocess_default_variables() {
   // The user object has no uid property when the database does not exist during
   // install. The user_access() check deals with issues when in maintenance mode
   // as uid is set but the user.module has not been included.
-  if (isset($user->uid) && function_exists('user_access')) {
+  if (isset($user->uid) && function_exists('Drupal\user_access')) {
     $variables['is_admin'] = user_access('access administration pages');
     $variables['logged_in'] = ($user->uid > 0);
   }
 
-  // drupal_is_front_page() might throw an exception.
+  // is_front_page() might throw an exception.
   try {
-    $variables['is_front'] = drupal_is_front_page();
+    $variables['is_front'] = is_front_page();
   }
   catch (Exception $e) {
     // If the database is not yet available, set default values for these
@@ -2296,11 +2301,11 @@ function template_process(&$variables, $hook) {
 
   // Flatten out attributes, title_attributes, and content_attributes.
   // Because this function can be called very often, and often with empty
-  // attributes, optimize performance by only calling drupal_attributes() if
+  // attributes, optimize performance by only calling attributes() if
   // necessary.
-  $variables['attributes'] = $variables['attributes_array'] ? drupal_attributes($variables['attributes_array']) : '';
-  $variables['title_attributes'] = $variables['title_attributes_array'] ? drupal_attributes($variables['title_attributes_array']) : '';
-  $variables['content_attributes'] = $variables['content_attributes_array'] ? drupal_attributes($variables['content_attributes_array']) : '';
+  $variables['attributes'] = $variables['attributes_array'] ? attributes($variables['attributes_array']) : '';
+  $variables['title_attributes'] = $variables['title_attributes_array'] ? attributes($variables['title_attributes_array']) : '';
+  $variables['content_attributes'] = $variables['content_attributes_array'] ? attributes($variables['content_attributes_array']) : '';
 }
 
 /**
@@ -2338,14 +2343,14 @@ function template_preprocess_html(&$variables) {
         // Add current suggestion to page classes to make it possible to theme
         // the page depending on the current page type (e.g. node, admin, user,
         // etc.) as well as more specific data like node-12 or node-edit.
-        $variables['classes_array'][] = drupal_html_class($suggestion);
+        $variables['classes_array'][] = html_class($suggestion);
       }
     }
   }
 
   // If on an individual node page, add the node type to body classes.
   if ($node = menu_get_object()) {
-    $variables['classes_array'][] = drupal_html_class('node-type-' . $node->type);
+    $variables['classes_array'][] = html_class('node-type-' . $node->type);
   }
 
   // Initializes attributes which are specific to the html and body elements.
@@ -2360,13 +2365,13 @@ function template_preprocess_html(&$variables) {
   if (theme_get_setting('toggle_favicon')) {
     $favicon = theme_get_setting('favicon');
     $type = theme_get_setting('favicon_mimetype');
-    drupal_add_html_head_link(array('rel' => 'shortcut icon', 'href' => drupal_strip_dangerous_protocols($favicon), 'type' => $type));
+    add_html_head_link(array('rel' => 'shortcut icon', 'href' => strip_dangerous_protocols($favicon), 'type' => $type));
   }
 
   // Construct page title.
-  if (drupal_get_title()) {
+  if (get_title()) {
     $head_title = array(
-      'title' => strip_tags(drupal_get_title()),
+      'title' => strip_tags(get_title()),
       'name' => check_plain(variable_get('site_name', 'Drupal')),
     );
   }
@@ -2398,7 +2403,7 @@ function template_preprocess_html(&$variables) {
  * Any changes to variables in this preprocessor should also be changed inside
  * template_preprocess_maintenance_page() to keep all of them consistent.
  *
- * @see drupal_render_page()
+ * @see render_page()
  * @see template_process_page()
  * @see page.tpl.php
  */
@@ -2423,7 +2428,7 @@ function template_preprocess_page(&$variables) {
 
   $variables['base_path']         = base_path();
   $variables['front_page']        = url();
-  $variables['feed_icons']        = drupal_get_feeds();
+  $variables['feed_icons']        = get_feeds();
   $variables['language']          = $GLOBALS['language'];
   $variables['language']->dir     = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
   $variables['logo']              = theme_get_setting('logo');
@@ -2459,10 +2464,10 @@ function template_process_page(&$variables) {
     // re-use the cache of an already rendered menu containing the active link
     // for the current page.
     // @see menu_tree_page_data()
-    $variables['breadcrumb'] = theme('breadcrumb', array('breadcrumb' => drupal_get_breadcrumb()));
+    $variables['breadcrumb'] = theme('breadcrumb', array('breadcrumb' => get_breadcrumb()));
   }
   if (!isset($variables['title'])) {
-    $variables['title'] = drupal_get_title();
+    $variables['title'] = get_title();
   }
 
   // Generate messages last in order to capture as many as possible for the
@@ -2484,20 +2489,20 @@ function template_process_page(&$variables) {
  */
 function template_process_html(&$variables) {
   // Flatten out html_attributes and body_attributes.
-  $variables['html_attributes'] = drupal_attributes($variables['html_attributes_array']);
-  $variables['body_attributes'] = drupal_attributes($variables['body_attributes_array']);
+  $variables['html_attributes'] = attributes($variables['html_attributes_array']);
+  $variables['body_attributes'] = attributes($variables['body_attributes_array']);
 
   // Render page_top and page_bottom into top level variables.
   $variables['page_top'] = drupal_render($variables['page']['page_top']);
   $variables['page_bottom'] = drupal_render($variables['page']['page_bottom']);
   // Place the rendered HTML for the page body into a top level variable.
   $variables['page']              = $variables['page']['#children'];
-  $variables['page_bottom'] .= drupal_get_js('footer');
+  $variables['page_bottom'] .= get_js('footer');
 
-  $variables['head']    = drupal_get_html_head();
-  $variables['css']     = drupal_add_css();
-  $variables['styles']  = drupal_get_css();
-  $variables['scripts'] = drupal_get_js();
+  $variables['head']    = get_html_head();
+  $variables['css']     = add_css();
+  $variables['styles']  = get_css();
+  $variables['scripts'] = get_js();
 }
 
 /**
@@ -2541,7 +2546,7 @@ function theme_get_suggestions($args, $base, $delimiter = '__') {
     // Remove slashes or null per SA-CORE-2009-003 and change - (hyphen) to _
     // (underscore).
     //
-    // When we discover templates in @see drupal_find_theme_templates,
+    // When we discover templates in @see find_theme_templates,
     // hyphens (-) are converted to underscores (_) before the theme hook
     // is registered. We do this because the hyphens used for delimiters
     // in hook suggestions cannot be used in the function names of the
@@ -2561,7 +2566,7 @@ function theme_get_suggestions($args, $base, $delimiter = '__') {
       $prefix .= $delimiter . $arg;
     }
   }
-  if (drupal_is_front_page()) {
+  if (is_front_page()) {
     // Front templates should be based on root only, not prefixed arguments.
     $suggestions[] = $base . $delimiter . 'front';
   }
@@ -2588,7 +2593,7 @@ function template_preprocess_maintenance_page(&$variables) {
   if (theme_get_setting('toggle_favicon')) {
     $favicon = theme_get_setting('favicon');
     $type = theme_get_setting('favicon_mimetype');
-    drupal_add_html_head_link(array('rel' => 'shortcut icon', 'href' => drupal_strip_dangerous_protocols($favicon), 'type' => $type));
+    add_html_head_link(array('rel' => 'shortcut icon', 'href' => strip_dangerous_protocols($favicon), 'type' => $type));
   }
 
   global $theme;
@@ -2596,10 +2601,10 @@ function template_preprocess_maintenance_page(&$variables) {
   $theme_data = list_themes();
   $regions = $theme_data[$theme]->info['regions'];
 
-  // Get all region content set with drupal_add_region_content().
+  // Get all region content set with add_region_content().
   foreach (array_keys($regions) as $region) {
     // Assign region to a region variable.
-    $region_content = drupal_get_region_content($region);
+    $region_content = get_region_content($region);
     isset($variables[$region]) ? $variables[$region] .= $region_content : $variables[$region] = $region_content;
   }
 
@@ -2613,9 +2618,9 @@ function template_preprocess_maintenance_page(&$variables) {
   }
 
   // Construct page title
-  if (drupal_get_title()) {
+  if (get_title()) {
     $head_title = array(
-      'title' => strip_tags(drupal_get_title()),
+      'title' => strip_tags(get_title()),
       'name' => variable_get('site_name', 'Drupal'),
     );
   }
@@ -2645,7 +2650,7 @@ function template_preprocess_maintenance_page(&$variables) {
   $variables['site_name']         = (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : '');
   $variables['site_slogan']       = (theme_get_setting('toggle_slogan') ? variable_get('site_slogan', '') : '');
   $variables['tabs']              = '';
-  $variables['title']             = drupal_get_title();
+  $variables['title']             = get_title();
 
   // Compile a list of classes that are going to be applied to the body element.
   $variables['classes_array'][] = 'in-maintenance';
@@ -2676,10 +2681,10 @@ function template_preprocess_maintenance_page(&$variables) {
  * @see maintenance-page.tpl.php
  */
 function template_process_maintenance_page(&$variables) {
-  $variables['head']    = drupal_get_html_head();
-  $variables['css']     = drupal_add_css();
-  $variables['styles']  = drupal_get_css();
-  $variables['scripts'] = drupal_get_js();
+  $variables['head']    = get_html_head();
+  $variables['css']     = add_css();
+  $variables['styles']  = get_css();
+  $variables['scripts'] = get_js();
 }
 
 /**
@@ -2689,7 +2694,7 @@ function template_process_maintenance_page(&$variables) {
  * pluggable template engine. Uses the region name to generate a template file
  * suggestions. If none are found, the default region.tpl.php is used.
  *
- * @see drupal_region_class()
+ * @see region_class()
  * @see region.tpl.php
  */
 function template_preprocess_region(&$variables) {
@@ -2697,6 +2702,6 @@ function template_preprocess_region(&$variables) {
   $variables['content'] = $variables['elements']['#children'];
   $variables['region'] = $variables['elements']['#region'];
 
-  $variables['classes_array'][] = drupal_region_class($variables['region']);
+  $variables['classes_array'][] = region_class($variables['region']);
   $variables['theme_hook_suggestions'][] = 'region__' . $variables['region'];
 }
diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc
index dce8801..9a488b6 100644
--- a/core/includes/theme.maintenance.inc
+++ b/core/includes/theme.maintenance.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -14,7 +15,7 @@
  * In other cases, Bartik is used, but this can be overridden by setting a
  * "maintenance_theme" key in the $conf variable in settings.php.
  */
-function _drupal_maintenance_theme() {
+function _maintenance_theme() {
   global $theme, $theme_key, $conf;
 
   // If $theme is already set, assume the others are set too, and do nothing.
@@ -22,12 +23,12 @@ function _drupal_maintenance_theme() {
     return;
   }
 
-  require_once DRUPAL_ROOT . '/' . variable_get('path_inc', 'core/includes/path.inc');
-  require_once DRUPAL_ROOT . '/core/includes/theme.inc';
-  require_once DRUPAL_ROOT . '/core/includes/common.inc';
-  require_once DRUPAL_ROOT . '/core/includes/unicode.inc';
-  require_once DRUPAL_ROOT . '/core/includes/file.inc';
-  require_once DRUPAL_ROOT . '/core/includes/module.inc';
+  require_once ROOT . '/' . variable_get('path_inc', 'core/includes/path.inc');
+  require_once ROOT . '/core/includes/theme.inc';
+  require_once ROOT . '/core/includes/common.inc';
+  require_once ROOT . '/core/includes/unicode.inc';
+  require_once ROOT . '/core/includes/file.inc';
+  require_once ROOT . '/core/includes/module.inc';
   unicode_check();
 
   // Install and update pages are treated differently to prevent theming overrides.
@@ -37,9 +38,9 @@ function _drupal_maintenance_theme() {
   else {
     // The bootstrap was not complete. So we are operating in a crippled
     // environment, we need to bootstrap just enough to allow hook invocations
-    // to work. See _drupal_log_error().
+    // to work. See _log_error().
     if (!class_exists('Database', FALSE)) {
-      require_once DRUPAL_ROOT . '/core/includes/database/database.inc';
+      require_once ROOT . '/core/includes/database/database.inc';
     }
 
     // We use the default theme as the maintenance theme. If a default theme
@@ -54,15 +55,15 @@ function _drupal_maintenance_theme() {
   }
 
   // Ensure that system.module is loaded.
-  if (!function_exists('_system_rebuild_theme_data')) {
+  if (!function_exists('Drupal\_system_rebuild_theme_data')) {
     $module_list['system']['filename'] = 'core/modules/system/system.module';
     module_list(TRUE, FALSE, FALSE, $module_list);
-    drupal_load('module', 'system');
+    load('module', 'system');
   }
 
   $themes = list_themes();
 
-  // list_themes() triggers a drupal_alter() in maintenance mode, but we can't
+  // list_themes() triggers a alter() in maintenance mode, but we can't
   // let themes alter the .info data until we know a theme's base themes. So
   // don't set global $theme until after list_themes() builds its cache.
   $theme = $custom_theme;
@@ -77,15 +78,15 @@ function _drupal_maintenance_theme() {
     $base_theme[] = $new_base_theme = $themes[$themes[$ancestor]->base_theme];
     $ancestor = $themes[$ancestor]->base_theme;
   }
-  _drupal_theme_initialize($themes[$theme], array_reverse($base_theme), '_theme_load_offline_registry');
+  _theme_initialize($themes[$theme], array_reverse($base_theme), '_theme_load_offline_registry');
 
   // These are usually added from system_init() -except maintenance.css.
   // When the database is inactive it's not called so we add it here.
-  $path = drupal_get_path('module', 'system');
-  drupal_add_css($path . '/system.base.css');
-  drupal_add_css($path . '/system.admin.css');
-  drupal_add_css($path . '/system.theme.css');
-  drupal_add_css($path . '/system.maintenance.css');
+  $path = get_path('module', 'system');
+  add_css($path . '/system.base.css');
+  add_css($path . '/system.admin.css');
+  add_css($path . '/system.theme.css');
+  add_css($path . '/system.maintenance.css');
 }
 
 /**
@@ -143,7 +144,7 @@ function theme_task_list($variables) {
  *   - content: The page content to show.
  */
 function theme_install_page($variables) {
-  drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
+  add_http_header('Content-Type', 'text/html; charset=utf-8');
   return theme('maintenance_page', $variables);
 }
 
@@ -159,7 +160,7 @@ function theme_install_page($variables) {
  *     FALSE can be useful to postpone the messages to a subsequent page.
  */
 function theme_update_page($variables) {
-  drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
+  add_http_header('Content-Type', 'text/html; charset=utf-8');
   return theme('maintenance_page', $variables);
 }
 
diff --git a/core/includes/token.inc b/core/includes/token.inc
index 86ac882..251bb7b 100644
--- a/core/includes/token.inc
+++ b/core/includes/token.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -87,7 +88,7 @@ function token_replace($text, array $data = array(), array $options = array()) {
 
   // Optionally alter the list of replacement values.
   if (!empty($options['callback'])) {
-    $function = $options['callback'];
+    $function = 'Drupal\\' . $options['callback'];
     $function($replacements, $data, $options);
   }
 
@@ -179,7 +180,7 @@ function token_generate($type, array $tokens, array $data = array(), array $opti
     'data' => $data,
     'options' => $options,
   );
-  drupal_alter('tokens', $replacements, $context);
+  alter('tokens', $replacements, $context);
 
   return $replacements;
 }
@@ -251,7 +252,7 @@ function token_info() {
   $data = &drupal_static(__FUNCTION__);
   if (!isset($data)) {
     $data = module_invoke_all('token_info');
-    drupal_alter('token_info', $data);
+    alter('token_info', $data);
   }
   return $data;
 }
diff --git a/core/includes/unicode.entities.inc b/core/includes/unicode.entities.inc
index 3b1fbb6..ffab3ae 100644
--- a/core/includes/unicode.entities.inc
+++ b/core/includes/unicode.entities.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/includes/unicode.inc b/core/includes/unicode.inc
index 50b7fe0..cf8e742 100644
--- a/core/includes/unicode.inc
+++ b/core/includes/unicode.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Indicates an error during check for PHP unicode support.
@@ -196,7 +197,7 @@ function drupal_xml_parser_create(&$data) {
   // Unsupported encodings are converted here into UTF-8.
   $php_supported = array('utf-8', 'iso-8859-1', 'us-ascii');
   if (!in_array(strtolower($encoding), $php_supported)) {
-    $out = drupal_convert_to_utf8($data, $encoding);
+    $out = convert_to_utf8($data, $encoding);
     if ($out !== FALSE) {
       $encoding = 'utf-8';
       $data = preg_replace('/^(<\?xml[^>]+encoding)="(.+?)"/', '\\1="utf-8"', $out);
@@ -225,7 +226,7 @@ function drupal_xml_parser_create(&$data) {
  * @return
  *   Converted data or FALSE.
  */
-function drupal_convert_to_utf8($data, $encoding) {
+function convert_to_utf8($data, $encoding) {
   if (function_exists('iconv')) {
     $out = @iconv($encoding, 'utf-8', $data);
   }
@@ -262,7 +263,7 @@ function drupal_convert_to_utf8($data, $encoding) {
  * @return
  *   The truncated string.
  */
-function drupal_truncate_bytes($string, $len) {
+function truncate_bytes($string, $len) {
   if (strlen($string) <= $len) {
     return $string;
   }
@@ -379,7 +380,7 @@ function mime_header_encode($string) {
     $len = strlen($string);
     $output = '';
     while ($len > 0) {
-      $chunk = drupal_truncate_bytes($string, $chunk_size);
+      $chunk = truncate_bytes($string, $chunk_size);
       $output .= ' =?UTF-8?B?' . base64_encode($chunk) . "?=\n";
       $c = strlen($chunk);
       $string = substr($string, $c);
@@ -395,9 +396,9 @@ function mime_header_encode($string) {
  */
 function mime_header_decode($header) {
   // First step: encoded chunks followed by other encoded chunks (need to collapse whitespace)
-  $header = preg_replace_callback('/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=\s+(?==\?)/', '_mime_header_decode', $header);
+  $header = preg_replace_callback('/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=\s+(?==\?)/', 'Drupal\_mime_header_decode', $header);
   // Second step: remaining chunks (do not collapse whitespace)
-  return preg_replace_callback('/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=/', '_mime_header_decode', $header);
+  return preg_replace_callback('/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=/', 'Drupal\_mime_header_decode', $header);
 }
 
 /**
@@ -410,7 +411,7 @@ function _mime_header_decode($matches) {
   // 3: Encoded data
   $data = ($matches[2] == 'B') ? base64_decode($matches[3]) : str_replace('_', ' ', quoted_printable_decode($matches[3]));
   if (strtolower($matches[1]) != 'utf-8') {
-    $data = drupal_convert_to_utf8($data, $matches[1]);
+    $data = convert_to_utf8($data, $matches[1]);
   }
   return $data;
 }
@@ -463,7 +464,7 @@ function drupal_strtoupper($text) {
     // Use C-locale for ASCII-only uppercase
     $text = strtoupper($text);
     // Case flip Latin-1 accented letters
-    $text = preg_replace_callback('/\xC3[\xA0-\xB6\xB8-\xBE]/', '_unicode_caseflip', $text);
+    $text = preg_replace_callback('/\xC3[\xA0-\xB6\xB8-\xBE]/', 'Drupal\_unicode_caseflip', $text);
     return $text;
   }
 }
@@ -482,7 +483,7 @@ function drupal_strtolower($text) {
     // Use C-locale for ASCII-only lowercase
     $text = strtolower($text);
     // Case flip Latin-1 accented letters
-    $text = preg_replace_callback('/\xC3[\x80-\x96\x98-\x9E]/', '_unicode_caseflip', $text);
+    $text = preg_replace_callback('/\xC3[\x80-\x96\x98-\x9E]/', 'Drupal\_unicode_caseflip', $text);
     return $text;
   }
 }
diff --git a/core/includes/update.inc b/core/includes/update.inc
index 613319a..1a70e05 100644
--- a/core/includes/update.inc
+++ b/core/includes/update.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, ReflectionFunction;
 
 /**
  * @file
@@ -60,7 +62,7 @@ function update_check_incompatibility($name, $type = 'module') {
   }
   if (!isset($file)
       || !isset($file->info['core'])
-      || $file->info['core'] != DRUPAL_CORE_COMPATIBILITY
+      || $file->info['core'] != CORE_COMPATIBILITY
       || version_compare(phpversion(), $file->info['php']) < 0) {
     return TRUE;
   }
@@ -81,15 +83,15 @@ function update_check_incompatibility($name, $type = 'module') {
 function update_prepare_d8_bootstrap() {
   // Allow the database system to work even if the registry has not been
   // created yet.
-  include_once DRUPAL_ROOT . '/core/includes/install.inc';
-  include_once DRUPAL_ROOT . '/core/modules/entity/entity.controller.inc';
-  drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
+  include_once ROOT . '/core/includes/install.inc';
+  include_once ROOT . '/core/modules/entity/entity.controller.inc';
+  bootstrap(BOOTSTRAP_DATABASE);
 
   // If the site has not updated to Drupal 8 yet, check to make sure that it is
   // running an up-to-date version of Drupal 7 before proceeding. Note this has
   // to happen AFTER the database bootstraps because of
-  // drupal_get_installed_schema_version().
-  $system_schema = drupal_get_installed_schema_version('system');
+  // get_installed_schema_version().
+  $system_schema = get_installed_schema_version('system');
   if ($system_schema < 8000) {
     $has_required_schema = $system_schema >= REQUIRED_D7_SCHEMA_VERSION;
     $requirements = array(
@@ -198,12 +200,12 @@ function update_module_add_to_system($modules = array()) {
     'description' => '',
     'package' => 'Other',
     'version' => NULL,
-    'php' => DRUPAL_MINIMUM_PHP,
+    'php' => MINIMUM_PHP,
     'files' => array(),
     'bootstrap' => 0,
   );
   foreach ($modules as $module) {
-    $module_info = drupal_parse_info_file('core/modules/' . $module . '/' . $module . '.info');
+    $module_info = parse_info_file('core/modules/' . $module . '/' . $module . '.info');
     db_insert('system')
       ->fields(array(
         'filename' => 'core/modules/' . $module . '/' . $module . '.module',
@@ -231,7 +233,7 @@ function update_module_add_to_system($modules = array()) {
 function update_fix_d8_requirements() {
   global $conf;
 
-  if (drupal_get_installed_schema_version('system') < 8000 && !variable_get('update_d8_requirements', FALSE)) {
+  if (get_installed_schema_version('system') < 8000 && !variable_get('update_d8_requirements', FALSE)) {
     // @todo: Make critical, first-run changes to the database here.
     variable_set('update_d8_requirements', TRUE);
   }
@@ -246,7 +248,7 @@ function update_module_enable(array $modules) {
     // installed module is always 0. Using 8000 here would be inconsistent
     // since $module_update_8000() may involve a schema change, and we want
     // to install the schema as it was before any updates were added.
-    $function = $module . '_schema_0';
+    $function = 'Drupal\\' . $module . '_schema_0';
     if (function_exists($function)) {
       $schema = $function();
       foreach ($schema as $table => $spec) {
@@ -263,7 +265,7 @@ function update_module_enable(array $modules) {
 
     // system_list_reset() is in module.inc but that would only be available
     // once the variable bootstrap is done.
-    require_once DRUPAL_ROOT . '/core/includes/module.inc';
+    require_once ROOT . '/core/includes/module.inc';
     system_list_reset();
     //  @todo: figure out what to do about hook_install() and hook_enable().
   }
@@ -282,9 +284,9 @@ function update_module_enable(array $modules) {
  * will be displayed at all.
  *
  * If it fails for whatever reason, it should throw an instance of
- * DrupalUpdateException with an appropriate error message, for example:
+ * UpdateException with an appropriate error message, for example:
  * @code
- * throw new DrupalUpdateException(t('Description of what went wrong'));
+ * throw new UpdateException(t('Description of what went wrong'));
  * @endcode
  *
  * If an exception is thrown, the current update and all updates that depend on
@@ -311,7 +313,7 @@ function update_module_enable(array $modules) {
  * @see update_resolve_dependencies()
  */
 function update_do_one($module, $number, $dependency_map, &$context) {
-  $function = $module . '_update_' . $number;
+  $function = 'Drupal\\' . $module . '_update_' . $number;
 
   // If this update was aborted in a previous step, or has a dependency that
   // was aborted in a previous step, go no further.
@@ -331,9 +333,9 @@ function update_do_one($module, $number, $dependency_map, &$context) {
     catch (Exception $e) {
       watchdog_exception('update', $e);
 
-      require_once DRUPAL_ROOT . '/core/includes/errors.inc';
-      $variables = _drupal_decode_exception($e);
-      // The exception message is run through check_plain() by _drupal_decode_exception().
+      require_once ROOT . '/core/includes/errors.inc';
+      $variables = _decode_exception($e);
+      // The exception message is run through check_plain() by _decode_exception().
       $ret['#abort'] = array('success' => FALSE, 'query' => t('%type: !message in %function (line %line of %file).', $variables));
     }
   }
@@ -358,7 +360,7 @@ function update_do_one($module, $number, $dependency_map, &$context) {
 
   // Record the schema update if it was completed successfully.
   if ($context['finished'] == 1 && empty($ret['#abort'])) {
-    drupal_set_installed_schema_version($module, $number);
+    set_installed_schema_version($module, $number);
   }
 
   $context['message'] = 'Updating ' . check_plain($module) . ' module';
@@ -367,7 +369,7 @@ function update_do_one($module, $number, $dependency_map, &$context) {
 /**
  * @class Exception class used to throw error if a module update fails.
  */
-class DrupalUpdateException extends Exception { }
+class UpdateException extends Exception { }
 
 /**
  * Start the database update batch process.
@@ -391,7 +393,7 @@ class DrupalUpdateException extends Exception { }
  *
  * @see update_resolve_dependencies()
  */
-function update_batch($start, $redirect = NULL, $url = NULL, $batch = array(), $redirect_callback = 'drupal_goto') {
+function update_batch($start, $redirect = NULL, $url = NULL, $batch = array(), $redirect_callback = 'redirect') {
   // During the update, bring the site offline so that schema changes do not
   // affect visiting users.
   $_SESSION['maintenance_mode'] = variable_get('maintenance_mode', FALSE);
@@ -419,7 +421,7 @@ function update_batch($start, $redirect = NULL, $url = NULL, $batch = array(), $
       // correct place. (The updates are already sorted, so we can simply base
       // this on the first one we come across in the above foreach loop.)
       if (isset($start[$update['module']])) {
-        drupal_set_installed_schema_version($update['module'], $update['number'] - 1);
+        set_installed_schema_version($update['module'], $update['number'] - 1);
         unset($start[$update['module']]);
       }
       // Add this update function to the batch.
@@ -458,7 +460,7 @@ function update_batch($start, $redirect = NULL, $url = NULL, $batch = array(), $
  */
 function update_finished($success, $results, $operations) {
   // Clear the caches in case the data has been updated.
-  drupal_flush_all_caches();
+  flush_all_caches();
 
   $_SESSION['update_results'] = $results;
   $_SESSION['update_success'] = $success;
@@ -494,14 +496,14 @@ function update_get_update_list() {
   // Make sure that the system module is first in the list of updates.
   $ret = array('system' => array());
 
-  $modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
+  $modules = get_installed_schema_version(NULL, FALSE, TRUE);
   foreach ($modules as $module => $schema_version) {
     // Skip uninstalled and incompatible modules.
     if ($schema_version == SCHEMA_UNINSTALLED || update_check_incompatibility($module)) {
       continue;
     }
     // Otherwise, get the list of updates defined by this module.
-    $updates = drupal_get_schema_versions($module);
+    $updates = get_schema_versions($module);
     if ($updates !== FALSE) {
       // module_invoke returns NULL for nonexisting hooks, so if no updates
       // are removed, it will == 0.
@@ -511,11 +513,11 @@ function update_get_update_list() {
         continue;
       }
 
-      $updates = drupal_map_assoc($updates);
+      $updates = map_assoc($updates);
       foreach (array_keys($updates) as $update) {
         if ($update > $schema_version) {
           // The description for an update comes from its Doxygen.
-          $func = new ReflectionFunction($module . '_update_' . $update);
+          $func = new ReflectionFunction('Drupal\\' . $module . '_update_' . $update);
           $description = str_replace(array("\n", '*', '/'), '', $func->getDocComment());
           $ret[$module]['pending'][$update] = "$update - $description";
           if (!isset($ret[$module]['start'])) {
@@ -547,7 +549,7 @@ function update_get_update_list() {
  *
  * In addition, the returned array also includes detailed information about the
  * dependency chain for each update, as provided by the depth-first search
- * algorithm in drupal_depth_first_search().
+ * algorithm in depth_first_search().
  *
  * @param $starting_updates
  *   An array whose keys contain the names of modules with updates to be run
@@ -560,7 +562,7 @@ function update_get_update_list() {
  *   request, arranged in the order in which the update functions should be
  *   run. (This includes the provided starting update for each module and all
  *   subsequent updates that are available.) The values are themselves arrays
- *   containing all the keys provided by the drupal_depth_first_search()
+ *   containing all the keys provided by the depth_first_search()
  *   algorithm, which encode detailed information about the dependency chain
  *   for this update function (for example: 'paths', 'reverse_paths', 'weight',
  *   and 'component'), as well as the following additional keys:
@@ -573,7 +575,7 @@ function update_get_update_list() {
  *   - 'module': The name of the module that this update function belongs to.
  *   - 'number': The number of this update function within that module.
  *
- * @see drupal_depth_first_search()
+ * @see depth_first_search()
  */
 function update_resolve_dependencies($starting_updates) {
   // Obtain a dependency graph for the requested update functions.
@@ -581,9 +583,9 @@ function update_resolve_dependencies($starting_updates) {
   $graph = update_build_dependency_graph($update_functions);
 
   // Perform the depth-first search and sort the results.
-  require_once DRUPAL_ROOT . '/core/includes/graph.inc';
-  drupal_depth_first_search($graph);
-  uasort($graph, 'drupal_sort_weight');
+  require_once ROOT . '/core/includes/graph.inc';
+  depth_first_search($graph);
+  uasort($graph, 'Drupal\sort_weight');
 
   foreach ($graph as $function => &$data) {
     $module = $data['module'];
@@ -634,7 +636,7 @@ function update_get_update_function_list($starting_updates) {
   $update_functions = array();
   foreach ($starting_updates as $module => $version) {
     $update_functions[$module] = array();
-    $updates = drupal_get_schema_versions($module);
+    $updates = get_schema_versions($module);
     if ($updates !== FALSE) {
       $max_version = max($updates);
       if ($version <= $max_version) {
@@ -677,18 +679,18 @@ function update_get_update_function_list($starting_updates) {
  *
  * @return
  *   A multidimensional array representing the dependency graph, suitable for
- *   passing in to drupal_depth_first_search(), but with extra information
+ *   passing in to depth_first_search(), but with extra information
  *   about each update function also included. Each array key contains the name
  *   of an update function, including all update functions from the provided
  *   list as well as any outside update functions which they directly depend
  *   on. Each value is an associative array containing the following keys:
  *   - 'edges': A representation of any other update functions that immediately
- *     depend on this one. See drupal_depth_first_search() for more details on
+ *     depend on this one. See depth_first_search() for more details on
  *     the format.
  *   - 'module': The name of the module that this update function belongs to.
  *   - 'number': The number of this update function within that module.
  *
- * @see drupal_depth_first_search()
+ * @see depth_first_search()
  * @see update_resolve_dependencies()
  */
 function update_build_dependency_graph($update_functions) {
@@ -747,7 +749,7 @@ function update_build_dependency_graph($update_functions) {
  *   provided list of updates to run; FALSE otherwise.
  */
 function update_is_missing($module, $number, $update_functions) {
-  return !isset($update_functions[$module][$number]) || !function_exists($update_functions[$module][$number]);
+  return !isset($update_functions[$module][$number]) || !function_exists('Drupal\\' . $update_functions[$module][$number]);
 }
 
 /**
@@ -763,7 +765,7 @@ function update_is_missing($module, $number, $update_functions) {
  *   performed; FALSE otherwise.
  */
 function update_already_performed($module, $number) {
-  return $number <= drupal_get_installed_schema_version($module);
+  return $number <= get_installed_schema_version($module);
 }
 
 /**
@@ -787,7 +789,7 @@ function update_retrieve_dependencies() {
   // the same order that module_invoke_all() does.
   $modules = db_query("SELECT name FROM {system} WHERE type = 'module' AND schema_version <> :schema ORDER BY weight ASC, name ASC", array(':schema' => SCHEMA_UNINSTALLED))->fetchCol();
   foreach ($modules as $module) {
-    $function = $module . '_update_dependencies';
+    $function = 'Drupal\\' . $module . '_update_dependencies';
     if (function_exists($function)) {
       $result = $function();
       // Each implementation of hook_update_dependencies() returns a
diff --git a/core/includes/updater.inc b/core/includes/updater.inc
index 9801629..f0e6c66 100644
--- a/core/includes/updater.inc
+++ b/core/includes/updater.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -18,7 +20,7 @@
  *   - It can return a list of "next steps" after an update or install.
  *   - In the future, it will most likely perform some of those steps as well.
  */
-interface DrupalUpdaterInterface {
+interface UpdaterInterface {
 
   /**
    * Checks if the project is installed.
@@ -98,7 +100,8 @@ class Updater {
     else {
       throw new UpdaterException(t('Unable to determine the type of the source directory.'));
     }
-    return new $updater($source);
+    $class = 'Drupal\\' . $updater;
+    return new $class($source);
   }
 
   /**
@@ -112,10 +115,10 @@ class Updater {
    */
   public static function getUpdaterFromDirectory($directory) {
     // Gets a list of possible implementing classes.
-    $updaters = drupal_get_updaters();
+    $updaters = get_updaters();
     foreach ($updaters as $updater) {
       $class = $updater['class'];
-      if (call_user_func(array($class, 'canUpdateDirectory'), $directory)) {
+      if (call_user_func(array('Drupal\\' . $class, 'canUpdateDirectory'), $directory)) {
         return $class;
       }
     }
@@ -141,7 +144,7 @@ class Updater {
       return FALSE;
     }
     foreach ($info_files as $info_file) {
-      if (drupal_substr($info_file->filename, 0, -5) == drupal_basename($directory)) {
+      if (drupal_substr($info_file->filename, 0, -5) == basename($directory)) {
         // Info file Has the same name as the directory, return it.
         return $info_file->uri;
       }
@@ -163,7 +166,7 @@ class Updater {
    *   The name of the project.
    */
   public static function getProjectName($directory) {
-    return drupal_basename($directory);
+    return basename($directory);
   }
 
   /**
@@ -177,7 +180,7 @@ class Updater {
    */
   public static function getProjectTitle($directory) {
     $info_file = self::findInfoFile($directory);
-    $info = drupal_parse_info_file($info_file);
+    $info = parse_info_file($info_file);
     if (empty($info)) {
       throw new UpdaterException(t('Unable to parse info file: %info_file.', array('%info_file' => $info_file)));
     }
diff --git a/core/includes/utility.inc b/core/includes/utility.inc
index 7d82f32..1281d97 100644
--- a/core/includes/utility.inc
+++ b/core/includes/utility.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
diff --git a/core/includes/uuid.inc b/core/includes/uuid.inc
index 57f2199..22aa23d 100644
--- a/core/includes/uuid.inc
+++ b/core/includes/uuid.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -37,7 +38,7 @@ class Uuid {
    * This constructor instantiates the correct UUID object.
    */
   public function __construct() {
-    $class = $this->determinePlugin();
+    $class = 'Drupal\\' . $this->determinePlugin();
     $this->plugin = new $class();
   }
 
@@ -127,7 +128,7 @@ class UuidCom implements UuidInterface {
  */
 class UuidPhp implements UuidInterface {
   public function generate() {
-    $hex = substr(hash('sha256', drupal_random_bytes(16)), 0, 32);
+    $hex = substr(hash('sha256', random_bytes(16)), 0, 32);
 
     // The field names refer to RFC 4122 section 4.1.2.
     $time_low = substr($hex, 0, 8);
diff --git a/core/includes/xmlrpc.inc b/core/includes/xmlrpc.inc
index b1c6f39..f3ad9b0 100644
--- a/core/includes/xmlrpc.inc
+++ b/core/includes/xmlrpc.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -175,8 +177,8 @@ function xmlrpc_message_parse($xmlrpc_message) {
   // Set XML parser to take the case of tags into account.
   xml_parser_set_option($xmlrpc_message->_parser, XML_OPTION_CASE_FOLDING, FALSE);
   // Set XML parser callback functions
-  xml_set_element_handler($xmlrpc_message->_parser, 'xmlrpc_message_tag_open', 'xmlrpc_message_tag_close');
-  xml_set_character_data_handler($xmlrpc_message->_parser, 'xmlrpc_message_cdata');
+  xml_set_element_handler($xmlrpc_message->_parser, 'Drupal\xmlrpc_message_tag_open', 'Drupal\xmlrpc_message_tag_close');
+  xml_set_character_data_handler($xmlrpc_message->_parser, 'Drupal\xmlrpc_message_cdata');
   xmlrpc_message_set($xmlrpc_message);
   if (!xml_parse($xmlrpc_message->_parser, $xmlrpc_message->message)) {
     return FALSE;
@@ -534,7 +536,7 @@ function xmlrpc_base64_get_xml($xmlrpc_base64) {
  *   are the arguments to pass to the respective method. If multiple methods
  *   are specified, a system.multicall is performed.
  * @param $options
- *   (optional) An array of options to pass along to drupal_http_request().
+ *   (optional) An array of options to pass along to http_request().
  *
  * @return
  *   A single response (single request) or an array of responses (multicall
@@ -562,7 +564,7 @@ function _xmlrpc($url, $args, $options = array()) {
   $options['method'] = 'POST';
   $options['headers']['Content-Type'] = 'text/xml';
   $options['data'] = $xmlrpc_request->xml;
-  $result = drupal_http_request($url, $options);
+  $result = http_request($url, $options);
   if ($result->code != 200) {
     xmlrpc_error($result->code, $result->error);
     return FALSE;
diff --git a/core/includes/xmlrpcs.inc b/core/includes/xmlrpcs.inc
index 118f652..4c91aa9 100644
--- a/core/includes/xmlrpcs.inc
+++ b/core/includes/xmlrpcs.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -45,7 +47,7 @@ function xmlrpc_server($callbacks) {
   // with those defined by modules implementing the _xmlrpc hook.
   // Built-in methods are overridable.
   $callbacks = array_merge($defaults, (array) $callbacks);
-  drupal_alter('xmlrpc', $callbacks);
+  alter('xmlrpc', $callbacks);
   foreach ($callbacks as $key => $callback) {
     // we could check for is_array($callback)
     if (is_int($key)) {
@@ -123,8 +125,8 @@ function xmlrpc_server_error($error, $message = FALSE) {
  */
 function xmlrpc_server_output($xml) {
   $xml = '<?xml version="1.0"?>' . "\n" . $xml;
-  drupal_add_http_header('Content-Length', strlen($xml));
-  drupal_add_http_header('Content-Type', 'text/xml');
+  add_http_header('Content-Length', strlen($xml));
+  add_http_header('Content-Type', 'text/xml');
   echo $xml;
   drupal_exit();
 }
@@ -184,7 +186,7 @@ function xmlrpc_server_call($xmlrpc_server, $methodname, $args) {
   if (!isset($xmlrpc_server->callbacks[$methodname])) {
     return xmlrpc_error(-32601, t('Server error. Requested method @methodname not specified.', array("@methodname" => $xmlrpc_server->message->methodname)));
   }
-  $method = $xmlrpc_server->callbacks[$methodname];
+  $method = 'Drupal\\' . $xmlrpc_server->callbacks[$methodname];
   $signature = $xmlrpc_server->signatures[$methodname];
 
   // If the method has a signature, validate the request against the signature
diff --git a/core/install.php b/core/install.php
index 7e908bd..1bd68ee 100644
--- a/core/install.php
+++ b/core/install.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -11,7 +12,7 @@ chdir('..');
 /**
  * Root directory of Drupal installation.
  */
-define('DRUPAL_ROOT', getcwd());
+define('ROOT', getcwd());
 
 /**
  * Global flag to indicate that site is in installation mode.
@@ -23,7 +24,7 @@ define('DRUPAL_ROOT', getcwd());
 define('MAINTENANCE_MODE', 'install');
 
 // Exit early if running an incompatible PHP version to avoid fatal errors.
-// The minimum version is specified explicitly, as DRUPAL_MINIMUM_PHP is not
+// The minimum version is specified explicitly, as MINIMUM_PHP is not
 // yet available. It is defined in bootstrap.inc, but it is not possible to
 // load that file yet as it would cause a fatal error on older versions of PHP.
 if (version_compare(PHP_VERSION, '5.3.2') < 0) {
@@ -32,5 +33,5 @@ if (version_compare(PHP_VERSION, '5.3.2') < 0) {
 }
 
 // Start the installer.
-require_once DRUPAL_ROOT . '/core/includes/install.core.inc';
+require_once ROOT . '/core/includes/install.core.inc';
 install_drupal();
diff --git a/core/modules/aggregator/aggregator-feed-source.tpl.php b/core/modules/aggregator/aggregator-feed-source.tpl.php
index f9cfa55..e37a53c 100644
--- a/core/modules/aggregator/aggregator-feed-source.tpl.php
+++ b/core/modules/aggregator/aggregator-feed-source.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/aggregator/aggregator-item.tpl.php b/core/modules/aggregator/aggregator-item.tpl.php
index 74b2284..c23f68c 100644
--- a/core/modules/aggregator/aggregator-item.tpl.php
+++ b/core/modules/aggregator/aggregator-item.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/aggregator/aggregator-summary-item.tpl.php b/core/modules/aggregator/aggregator-summary-item.tpl.php
index f9199a5..b7b3b75 100644
--- a/core/modules/aggregator/aggregator-summary-item.tpl.php
+++ b/core/modules/aggregator/aggregator-summary-item.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/aggregator/aggregator-summary-items.tpl.php b/core/modules/aggregator/aggregator-summary-items.tpl.php
index 4a0551d..d547067 100644
--- a/core/modules/aggregator/aggregator-summary-items.tpl.php
+++ b/core/modules/aggregator/aggregator-summary-items.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/aggregator/aggregator-wrapper.tpl.php b/core/modules/aggregator/aggregator-wrapper.tpl.php
index 7cac5bf..c8a55a8 100644
--- a/core/modules/aggregator/aggregator-wrapper.tpl.php
+++ b/core/modules/aggregator/aggregator-wrapper.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/aggregator/aggregator.admin.inc b/core/modules/aggregator/aggregator.admin.inc
index 93319bf..659acb3 100644
--- a/core/modules/aggregator/aggregator.admin.inc
+++ b/core/modules/aggregator/aggregator.admin.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -71,7 +73,7 @@ function aggregator_view() {
  * @see aggregator_form_feed_submit()
  */
 function aggregator_form_feed($form, &$form_state, stdClass $feed = NULL) {
-  $period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
+  $period = map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'Drupal\format_interval');
   $period[AGGREGATOR_CLEAR_NEVER] = t('Never');
 
   $form['title'] = array('#type' => 'textfield',
@@ -97,7 +99,7 @@ function aggregator_form_feed($form, &$form_state, stdClass $feed = NULL) {
   $form['block'] = array('#type' => 'select',
     '#title' => t('News items in block'),
     '#default_value' => isset($feed->block) ? $feed->block : 5,
-    '#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)),
+    '#options' => map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)),
     '#description' => t("Drupal can make a block with the most recent news items of this feed. You can <a href=\"@block-admin\">configure blocks</a> to be displayed in the sidebar of your page. This setting lets you configure the number of news items to show in this feed's block. If you choose '0' this feed's block will be disabled.", array('@block-admin' => url('admin/structure/block'))),
   );
 
@@ -183,7 +185,7 @@ function aggregator_form_feed_submit($form, &$form_state) {
   aggregator_save_feed($form_state['values']);
   if (isset($form_state['values']['fid'])) {
     if (isset($form_state['values']['title'])) {
-      drupal_set_message(t('The feed %feed has been updated.', array('%feed' => $form_state['values']['title'])));
+      set_message(t('The feed %feed has been updated.', array('%feed' => $form_state['values']['title'])));
       if (arg(0) == 'admin') {
         $form_state['redirect'] = 'admin/config/services/aggregator/';
         return;
@@ -195,7 +197,7 @@ function aggregator_form_feed_submit($form, &$form_state) {
     }
     else {
       watchdog('aggregator', 'Feed %feed deleted.', array('%feed' => $title));
-      drupal_set_message(t('The feed %feed has been deleted.', array('%feed' => $title)));
+      set_message(t('The feed %feed has been deleted.', array('%feed' => $title)));
       if (arg(0) == 'admin') {
         $form_state['redirect'] = 'admin/config/services/aggregator/';
         return;
@@ -208,7 +210,7 @@ function aggregator_form_feed_submit($form, &$form_state) {
   }
   else {
     watchdog('aggregator', 'Feed %feed added.', array('%feed' => $form_state['values']['title']), WATCHDOG_NOTICE, l(t('view'), 'admin/config/services/aggregator'));
-    drupal_set_message(t('The feed %feed has been added.', array('%feed' => $form_state['values']['title'])));
+    set_message(t('The feed %feed has been added.', array('%feed' => $form_state['values']['title'])));
   }
 }
 
@@ -260,7 +262,7 @@ function aggregator_admin_remove_feed_submit($form, &$form_state) {
  * @see aggregator_form_opml_submit()
  */
 function aggregator_form_opml($form, &$form_state) {
-  $period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
+  $period = map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'Drupal\format_interval');
 
   $form['upload'] = array(
     '#type' => 'file',
@@ -283,12 +285,12 @@ function aggregator_form_opml($form, &$form_state) {
   $form['block'] = array('#type' => 'select',
     '#title' => t('News items in block'),
     '#default_value' => 5,
-    '#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)),
+    '#options' => map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)),
     '#description' => t("Drupal can make a block with the most recent news items of a feed. You can <a href=\"@block-admin\">configure blocks</a> to be displayed in the sidebar of your page. This setting lets you configure the number of news items to show in a feed's block. If you choose '0' these feeds' blocks will be disabled.", array('@block-admin' => url('admin/structure/block'))),
   );
 
   // Handling of categories.
-  $options = array_map('check_plain', db_query("SELECT cid, title FROM {aggregator_category} ORDER BY title")->fetchAllKeyed());
+  $options = array_map('Drupal\check_plain', db_query("SELECT cid, title FROM {aggregator_category} ORDER BY title")->fetchAllKeyed());
   if ($options) {
     $form['category'] = array(
       '#type' => 'checkboxes',
@@ -335,7 +337,7 @@ function aggregator_form_opml_submit($form, &$form_state) {
     $data = file_get_contents($file->uri);
   }
   else {
-    $response = drupal_http_request($form_state['values']['remote']);
+    $response = http_request($form_state['values']['remote']);
     if (!isset($response->error)) {
       $data = $response->data;
     }
@@ -343,7 +345,7 @@ function aggregator_form_opml_submit($form, &$form_state) {
 
   $feeds = _aggregator_parse_opml($data);
   if (empty($feeds)) {
-    drupal_set_message(t('No new feed has been added.'));
+    set_message(t('No new feed has been added.'));
     return;
   }
 
@@ -352,7 +354,7 @@ function aggregator_form_opml_submit($form, &$form_state) {
   foreach ($feeds as $feed) {
     // Ensure URL is valid.
     if (!valid_url($feed['url'], TRUE)) {
-      drupal_set_message(t('The URL %url is invalid.', array('%url' => $feed['url'])), 'warning');
+      set_message(t('The URL %url is invalid.', array('%url' => $feed['url'])), 'warning');
       continue;
     }
 
@@ -360,18 +362,18 @@ function aggregator_form_opml_submit($form, &$form_state) {
     $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE title = :title OR url = :url", array(':title' => $feed['title'], ':url' => $feed['url']));
     foreach ($result as $old) {
       if (strcasecmp($old->title, $feed['title']) == 0) {
-        drupal_set_message(t('A feed named %title already exists.', array('%title' => $old->title)), 'warning');
+        set_message(t('A feed named %title already exists.', array('%title' => $old->title)), 'warning');
         continue 2;
       }
       if (strcasecmp($old->url, $feed['url']) == 0) {
-        drupal_set_message(t('A feed with the URL %url already exists.', array('%url' => $old->url)), 'warning');
+        set_message(t('A feed with the URL %url already exists.', array('%url' => $old->url)), 'warning');
         continue 2;
       }
     }
 
     $form_state['values']['title'] = $feed['title'];
     $form_state['values']['url'] = $feed['url'];
-    drupal_form_submit('aggregator_form_feed', $form_state);
+    form_submit('aggregator_form_feed', $form_state);
   }
 
   $form_state['redirect'] = 'admin/config/services/aggregator';
@@ -422,7 +424,7 @@ function _aggregator_parse_opml($opml) {
  */
 function aggregator_admin_refresh_feed($feed) {
   aggregator_refresh($feed);
-  drupal_goto('admin/config/services/aggregator');
+  redirect('admin/config/services/aggregator');
 }
 
 /**
@@ -621,7 +623,7 @@ function aggregator_form_category_submit($form, &$form_state) {
   aggregator_save_category($form_state['values']);
   if (isset($form_state['values']['cid'])) {
     if (isset($form_state['values']['title'])) {
-      drupal_set_message(t('The category %category has been updated.', array('%category' => $form_state['values']['title'])));
+      set_message(t('The category %category has been updated.', array('%category' => $form_state['values']['title'])));
       if (arg(0) == 'admin') {
         $form_state['redirect'] = 'admin/config/services/aggregator/';
         return;
@@ -633,7 +635,7 @@ function aggregator_form_category_submit($form, &$form_state) {
     }
     else {
       watchdog('aggregator', 'Category %category deleted.', array('%category' => $title));
-      drupal_set_message(t('The category %category has been deleted.', array('%category' => $title)));
+      set_message(t('The category %category has been deleted.', array('%category' => $title)));
       if (arg(0) == 'admin') {
         $form_state['redirect'] = 'admin/config/services/aggregator/';
         return;
@@ -646,6 +648,6 @@ function aggregator_form_category_submit($form, &$form_state) {
   }
   else {
     watchdog('aggregator', 'Category %category added.', array('%category' => $form_state['values']['title']), WATCHDOG_NOTICE, l(t('view'), 'admin/config/services/aggregator'));
-    drupal_set_message(t('The category %category has been added.', array('%category' => $form_state['values']['title'])));
+    set_message(t('The category %category has been added.', array('%category' => $form_state['values']['title'])));
   }
 }
diff --git a/core/modules/aggregator/aggregator.api.php b/core/modules/aggregator/aggregator.api.php
index 0f708eb..601c9ac 100644
--- a/core/modules/aggregator/aggregator.api.php
+++ b/core/modules/aggregator/aggregator.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/aggregator/aggregator.fetcher.inc b/core/modules/aggregator/aggregator.fetcher.inc
index 831ea78..87fb082 100644
--- a/core/modules/aggregator/aggregator.fetcher.inc
+++ b/core/modules/aggregator/aggregator.fetcher.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -31,7 +32,7 @@ function aggregator_aggregator_fetch($feed) {
   }
 
   // Request feed.
-  $result = drupal_http_request($feed->url, array('headers' => $headers));
+  $result = http_request($feed->url, array('headers' => $headers));
 
   // Process HTTP response code.
   switch ($result->code) {
@@ -54,7 +55,7 @@ function aggregator_aggregator_fetch($feed) {
       break;
     default:
       watchdog('aggregator', 'The feed from %site seems to be broken due to "%error".', array('%site' => $feed->title, '%error' => $result->code . ' ' . $result->error), WATCHDOG_WARNING);
-      drupal_set_message(t('The feed from %site seems to be broken because of error "%error".', array('%site' => $feed->title, '%error' => $result->code . ' ' . $result->error)));
+      set_message(t('The feed from %site seems to be broken because of error "%error".', array('%site' => $feed->title, '%error' => $result->code . ' ' . $result->error)));
   }
 
   return $feed->source_string === FALSE ? FALSE : TRUE;
diff --git a/core/modules/aggregator/aggregator.install b/core/modules/aggregator/aggregator.install
index eecd14f..d99c712 100644
--- a/core/modules/aggregator/aggregator.install
+++ b/core/modules/aggregator/aggregator.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module
index bb66cbe..5e14657 100644
--- a/core/modules/aggregator/aggregator.module
+++ b/core/modules/aggregator/aggregator.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -106,7 +107,7 @@ function aggregator_menu() {
   );
   $items['admin/config/services/aggregator/add/feed'] = array(
     'title' => 'Add feed',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('aggregator_form_feed'),
     'access arguments' => array('administer news feeds'),
     'type' => MENU_LOCAL_ACTION,
@@ -114,7 +115,7 @@ function aggregator_menu() {
   );
   $items['admin/config/services/aggregator/add/category'] = array(
     'title' => 'Add category',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('aggregator_form_category'),
     'access arguments' => array('administer news feeds'),
     'type' => MENU_LOCAL_ACTION,
@@ -122,7 +123,7 @@ function aggregator_menu() {
   );
   $items['admin/config/services/aggregator/add/opml'] = array(
     'title' => 'Import OPML',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('aggregator_form_opml'),
     'access arguments' => array('administer news feeds'),
     'type' => MENU_LOCAL_ACTION,
@@ -130,7 +131,7 @@ function aggregator_menu() {
   );
   $items['admin/config/services/aggregator/remove/%aggregator_feed'] = array(
     'title' => 'Remove items',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('aggregator_admin_remove_feed', 5),
     'access arguments' => array('administer news feeds'),
     'file' => 'aggregator.admin.inc',
@@ -150,7 +151,7 @@ function aggregator_menu() {
   $items['admin/config/services/aggregator/settings'] = array(
     'title' => 'Settings',
     'description' => 'Configure the behavior of the feed aggregator, including when to discard feed items and how to present feed items and categories.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('aggregator_admin_form'),
     'access arguments' => array('administer news feeds'),
     'type' => MENU_LOCAL_TASK,
@@ -204,7 +205,7 @@ function aggregator_menu() {
   );
   $items['aggregator/categories/%aggregator_category/categorize'] = array(
     'title' => 'Categorize',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('aggregator_page_category_form', 2),
     'access arguments' => array('administer news feeds'),
     'type' => MENU_LOCAL_TASK,
@@ -212,7 +213,7 @@ function aggregator_menu() {
   );
   $items['aggregator/categories/%aggregator_category/configure'] = array(
     'title' => 'Configure',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('aggregator_form_category', 2),
     'access arguments' => array('administer news feeds'),
     'type' => MENU_LOCAL_TASK,
@@ -232,7 +233,7 @@ function aggregator_menu() {
   );
   $items['aggregator/sources/%aggregator_feed/categorize'] = array(
     'title' => 'Categorize',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('aggregator_page_source_form', 2),
     'access arguments' => array('administer news feeds'),
     'type' => MENU_LOCAL_TASK,
@@ -240,7 +241,7 @@ function aggregator_menu() {
   );
   $items['aggregator/sources/%aggregator_feed/configure'] = array(
     'title' => 'Configure',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('aggregator_form_feed', 2),
     'access arguments' => array('administer news feeds'),
     'type' => MENU_LOCAL_TASK,
@@ -249,14 +250,14 @@ function aggregator_menu() {
   );
   $items['admin/config/services/aggregator/edit/feed/%aggregator_feed'] = array(
     'title' => 'Edit feed',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('aggregator_form_feed', 6),
     'access arguments' => array('administer news feeds'),
     'file' => 'aggregator.admin.inc',
   );
   $items['admin/config/services/aggregator/edit/category/%aggregator_category'] = array(
     'title' => 'Edit category',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('aggregator_form_category', 6),
     'access arguments' => array('administer news feeds'),
     'file' => 'aggregator.admin.inc',
@@ -317,7 +318,7 @@ function aggregator_cron() {
     ':time' => REQUEST_TIME,
     ':never' => AGGREGATOR_CLEAR_NEVER
   ));
-  $queue = DrupalQueue::get('aggregator_feeds');
+  $queue = Queue::get('aggregator_feeds');
   foreach ($result as $feed) {
     if ($queue->createItem($feed)) {
       // Add timestamp to avoid queueing item more than once.
@@ -373,7 +374,7 @@ function aggregator_block_configure($delta = '') {
       '#type' => 'select',
       '#title' => t('Number of news items in block'),
       '#default_value' => $value,
-      '#options' => drupal_map_assoc(range(2, 20)),
+      '#options' => map_assoc(range(2, 20)),
     );
     return $form;
   }
@@ -596,15 +597,15 @@ function _aggregator_get_variables() {
   // Fetch the feed.
   $fetcher = variable_get('aggregator_fetcher', 'aggregator');
   if ($fetcher == 'aggregator') {
-    include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/aggregator.fetcher.inc';
+    include_once ROOT . '/' . get_path('module', 'aggregator') . '/aggregator.fetcher.inc';
   }
   $parser = variable_get('aggregator_parser', 'aggregator');
   if ($parser == 'aggregator') {
-    include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/aggregator.parser.inc';
+    include_once ROOT . '/' . get_path('module', 'aggregator') . '/aggregator.parser.inc';
   }
   $processors = variable_get('aggregator_processors', array('aggregator'));
   if (in_array('aggregator', $processors)) {
-    include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/aggregator.processor.inc';
+    include_once ROOT . '/' . get_path('module', 'aggregator') . '/aggregator.processor.inc';
   }
   return array($fetcher, $parser, $processors);
 }
@@ -651,7 +652,7 @@ function aggregator_refresh($feed) {
       }
 
       watchdog('aggregator', 'There is new syndicated content from %site.', array('%site' => $feed->title));
-      drupal_set_message(t('There is new syndicated content from %site.', array('%site' => $feed->title)));
+      set_message(t('There is new syndicated content from %site.', array('%site' => $feed->title)));
 
       // If there are items on the feed, let all enabled processors do their work on it.
       if (@count($feed->items)) {
@@ -662,7 +663,7 @@ function aggregator_refresh($feed) {
     }
   }
   else {
-    drupal_set_message(t('There is no new syndicated content from %site.', array('%site' => $feed->title)));
+    set_message(t('There is no new syndicated content from %site.', array('%site' => $feed->title)));
   }
 
   // Regardless of successful or not, indicate that this feed has been checked.
@@ -672,7 +673,7 @@ function aggregator_refresh($feed) {
     ->execute();
 
   // Expire old feed items.
-  if (function_exists('aggregator_expire')) {
+  if (function_exists('Drupal\aggregator_expire')) {
     aggregator_expire($feed);
   }
 }
@@ -775,7 +776,7 @@ function aggregator_sanitize_configuration() {
 }
 
 /**
- * Helper function for drupal_map_assoc.
+ * Helper function for map_assoc.
  *
  * @param $count
  *   Items count.
diff --git a/core/modules/aggregator/aggregator.pages.inc b/core/modules/aggregator/aggregator.pages.inc
index 353eedc..90b7694 100644
--- a/core/modules/aggregator/aggregator.pages.inc
+++ b/core/modules/aggregator/aggregator.pages.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -13,7 +14,7 @@
  * @see aggregator_menu()
  */
 function aggregator_page_last() {
-  drupal_add_feed('aggregator/rss', variable_get('site_name', 'Drupal') . ' ' . t('aggregator'));
+  add_feed('aggregator/rss', variable_get('site_name', 'Drupal') . ' ' . t('aggregator'));
 
   $items = aggregator_load_feed_items('sum');
 
@@ -31,7 +32,7 @@ function aggregator_page_last() {
  * @see aggregator_menu()
  */
 function aggregator_page_source($feed) {
-  drupal_set_title($feed->title);
+  set_title($feed->title);
   $feed_source = theme('aggregator_feed_source', array('feed' => $feed));
 
   // It is safe to include the fid in the query because it's loaded from the
@@ -69,7 +70,7 @@ function aggregator_page_source_form($form, $form_state, $feed) {
  * @ingroup forms
  */
 function aggregator_page_category($category) {
-  drupal_add_feed('aggregator/rss/' . $category['cid'], variable_get('site_name', 'Drupal') . ' ' . t('aggregator - @title', array('@title' => $category['title'])));
+  add_feed('aggregator/rss/' . $category['cid'], variable_get('site_name', 'Drupal') . ' ' . t('aggregator - @title', array('@title' => $category['title'])));
 
   // It is safe to include the cid in the query because it's loaded from the
   // database by aggregator_category_load().
@@ -267,7 +268,7 @@ function aggregator_categorize_items_submit($form, &$form_state) {
       }
     }
   }
-  drupal_set_message(t('The categories have been saved.'));
+  set_message(t('The categories have been saved.'));
 }
 
 /**
@@ -294,7 +295,7 @@ function theme_aggregator_categorize_items($variables) {
   }
   $output .= theme('table', array('header' => array('', t('Categorize')), 'rows' => $rows));
   $output .= drupal_render($form['submit']);
-  $output .= drupal_render_children($form);
+  $output .= render_children($form);
 
   return theme('aggregator_wrapper', array('content' => $output));
 }
@@ -433,7 +434,7 @@ function theme_aggregator_page_rss($variables) {
   $feeds = $variables['feeds'];
   $category = $variables['category'];
 
-  drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
+  add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
 
   $items = '';
   $feed_length = variable_get('feed_item_length', 'fulltext');
@@ -502,7 +503,7 @@ function aggregator_page_opml($cid = NULL) {
 function theme_aggregator_page_opml($variables) {
   $feeds = $variables['feeds'];
 
-  drupal_add_http_header('Content-Type', 'text/xml; charset=utf-8');
+  add_http_header('Content-Type', 'text/xml; charset=utf-8');
 
   $output  = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
   $output .= "<opml version=\"1.1\">\n";
diff --git a/core/modules/aggregator/aggregator.parser.inc b/core/modules/aggregator/aggregator.parser.inc
index 0f594d4..2f42b9f 100644
--- a/core/modules/aggregator/aggregator.parser.inc
+++ b/core/modules/aggregator/aggregator.parser.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -75,12 +76,12 @@ function aggregator_parse_feed(&$data, $feed) {
 
   // Parse the data.
   $xml_parser = drupal_xml_parser_create($data);
-  xml_set_element_handler($xml_parser, 'aggregator_element_start', 'aggregator_element_end');
-  xml_set_character_data_handler($xml_parser, 'aggregator_element_data');
+  xml_set_element_handler($xml_parser, 'Drupal\aggregator_element_start', 'Drupal\aggregator_element_end');
+  xml_set_character_data_handler($xml_parser, 'Drupal\aggregator_element_data');
 
   if (!xml_parse($xml_parser, $data, 1)) {
     watchdog('aggregator', 'The feed from %site seems to be broken due to an error "%error" on line %line.', array('%site' => $feed->title, '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser)), WATCHDOG_WARNING);
-    drupal_set_message(t('The feed from %site seems to be broken because of error "%error" on line %line.', array('%site' => $feed->title, '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser))), 'error');
+    set_message(t('The feed from %site seems to be broken because of error "%error" on line %line.', array('%site' => $feed->title, '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser))), 'error');
     return FALSE;
   }
   xml_parser_free($xml_parser);
diff --git a/core/modules/aggregator/aggregator.processor.inc b/core/modules/aggregator/aggregator.processor.inc
index 7fa86a9..d47ca98 100644
--- a/core/modules/aggregator/aggregator.processor.inc
+++ b/core/modules/aggregator/aggregator.processor.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -60,7 +61,7 @@ function aggregator_aggregator_remove($feed) {
     ->condition('fid', $feed->fid)
     ->execute();
 
-  drupal_set_message(t('The news items from %site have been removed.', array('%site' => $feed->title)));
+  set_message(t('The news items from %site have been removed.', array('%site' => $feed->title)));
 }
 
 /**
@@ -72,8 +73,8 @@ function aggregator_aggregator_remove($feed) {
 function aggregator_form_aggregator_admin_form_alter(&$form, $form_state) {
   if (in_array('aggregator', variable_get('aggregator_processors', array('aggregator')))) {
     $info = module_invoke('aggregator', 'aggregator_process', 'info');
-    $items = drupal_map_assoc(array(3, 5, 10, 15, 20, 25), '_aggregator_items');
-    $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
+    $items = map_assoc(array(3, 5, 10, 15, 20, 25), 'Drupal\_aggregator_items');
+    $period = map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'Drupal\format_interval');
     $period[AGGREGATOR_CLEAR_NEVER] = t('Never');
 
     // Only wrap into a collapsible fieldset if there is a basic configuration.
@@ -118,7 +119,7 @@ function aggregator_form_aggregator_admin_form_alter(&$form, $form_state) {
       '#type' => 'select',
       '#title' => t('Length of trimmed description'),
       '#default_value' => variable_get('aggregator_teaser_length', 600),
-      '#options' => drupal_map_assoc(array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000), '_aggregator_characters'),
+      '#options' => map_assoc(array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000), 'Drupal\_aggregator_characters'),
       '#description' => t("The maximum number of characters used in the trimmed version of content.")
     );
 
@@ -128,7 +129,7 @@ function aggregator_form_aggregator_admin_form_alter(&$form, $form_state) {
 /**
  * Creates display text for teaser length option values.
  *
- * Callback for drupal_map_assoc() within
+ * Callback for map_assoc() within
  * aggregator_form_aggregator_admin_form_alter().
  */
 function _aggregator_characters($length) {
diff --git a/core/modules/aggregator/aggregator.test b/core/modules/aggregator/aggregator.test
index fa8b503..7f349a2 100644
--- a/core/modules/aggregator/aggregator.test
+++ b/core/modules/aggregator/aggregator.test
@@ -1,11 +1,12 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
  * Tests for aggregator.module.
  */
 
-class AggregatorTestCase extends DrupalWebTestCase {
+class AggregatorTestCase extends WebTestCase {
   function setUp() {
     parent::setUp('aggregator', 'aggregator_test');
     $web_user = $this->drupalCreateUser(array('administer news feeds', 'access news feeds', 'create article content'));
@@ -257,13 +258,13 @@ EOF;
   }
 
   function getRSS091Sample() {
-    return $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'aggregator') . '/tests/aggregator_test_rss091.xml';
+    return $GLOBALS['base_url'] . '/' . get_path('module', 'aggregator') . '/tests/aggregator_test_rss091.xml';
   }
 
   function getAtomSample() {
     // The content of this sample ATOM feed is based directly off of the
     // example provided in RFC 4287.
-    return $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'aggregator') . '/tests/aggregator_test_atom.xml';
+    return $GLOBALS['base_url'] . '/' . get_path('module', 'aggregator') . '/tests/aggregator_test_atom.xml';
   }
 
   /**
diff --git a/core/modules/aggregator/tests/aggregator_test.module b/core/modules/aggregator/tests/aggregator_test.module
index 2d26a5d..3f86fca 100644
--- a/core/modules/aggregator/tests/aggregator_test.module
+++ b/core/modules/aggregator/tests/aggregator_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Implements hook_menu().
@@ -24,7 +25,7 @@ function aggregator_test_menu() {
  */
 function aggregator_test_feed($use_last_modified = FALSE, $use_etag = FALSE) {
   $last_modified = strtotime('Sun, 19 Nov 1978 05:00:00 GMT');
-  $etag = drupal_hash_base64($last_modified);
+  $etag = hash_base64($last_modified);
 
   $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE;
   $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : FALSE;
@@ -32,24 +33,24 @@ function aggregator_test_feed($use_last_modified = FALSE, $use_etag = FALSE) {
   // Send appropriate response. We respond with a 304 not modified on either
   // etag or on last modified.
   if ($use_last_modified) {
-    drupal_add_http_header('Last-Modified', gmdate(DATE_RFC1123, $last_modified));
+    add_http_header('Last-Modified', gmdate(DATE_RFC1123, $last_modified));
   }
   if ($use_etag) {
-    drupal_add_http_header('ETag', $etag);
+    add_http_header('ETag', $etag);
   }
   // Return 304 not modified if either last modified or etag match.
   if ($last_modified == $if_modified_since || $etag == $if_none_match) {
-    drupal_add_http_header('Status', '304 Not Modified');
+    add_http_header('Status', '304 Not Modified');
     return;
   }
 
   // The following headers force validation of cache:
-  drupal_add_http_header('Expires', 'Sun, 19 Nov 1978 05:00:00 GMT');
-  drupal_add_http_header('Cache-Control', 'must-revalidate');
-  drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
+  add_http_header('Expires', 'Sun, 19 Nov 1978 05:00:00 GMT');
+  add_http_header('Cache-Control', 'must-revalidate');
+  add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
 
   // Read actual feed from file.
-  $file_name = DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/tests/aggregator_test_rss091.xml';
+  $file_name = ROOT . '/' . get_path('module', 'aggregator') . '/tests/aggregator_test_rss091.xml';
   $handle = fopen($file_name, 'r');
   $feed = fread($handle, filesize($file_name));
   fclose($handle);
diff --git a/core/modules/block/block-admin-display-form.tpl.php b/core/modules/block/block-admin-display-form.tpl.php
index 0ce2b6b..0291f19 100644
--- a/core/modules/block/block-admin-display-form.tpl.php
+++ b/core/modules/block/block-admin-display-form.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -27,11 +28,11 @@
 ?>
 <?php
   // Add table javascript.
-  drupal_add_js('core/misc/tableheader.js');
-  drupal_add_js(drupal_get_path('module', 'block') . '/block.js');
+  add_js('core/misc/tableheader.js');
+  add_js(get_path('module', 'block') . '/block.js');
   foreach ($block_regions as $region => $title) {
-    drupal_add_tabledrag('blocks', 'match', 'sibling', 'block-region-select', 'block-region-' . $region, NULL, FALSE);
-    drupal_add_tabledrag('blocks', 'order', 'sibling', 'block-weight', 'block-weight-' . $region);
+    add_tabledrag('blocks', 'match', 'sibling', 'block-region-select', 'block-region-' . $region, NULL, FALSE);
+    add_tabledrag('blocks', 'order', 'sibling', 'block-weight', 'block-weight-' . $region);
   }
 ?>
 <table id="blocks" class="sticky-enabled">
diff --git a/core/modules/block/block.admin.inc b/core/modules/block/block.admin.inc
index 2b3c2dd..1b805a6 100644
--- a/core/modules/block/block.admin.inc
+++ b/core/modules/block/block.admin.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, stdClass;
 
 /**
  * @file
@@ -13,7 +15,7 @@
  * @see block_menu()
  */
 function block_admin_demo($theme = NULL) {
-  drupal_add_css(drupal_get_path('module', 'block') . '/block.admin.css');
+  add_css(get_path('module', 'block') . '/block.admin.css');
   return '';
 }
 
@@ -31,7 +33,7 @@ function block_admin_demo($theme = NULL) {
 function block_admin_display($theme = NULL) {
   global $theme_key;
 
-  drupal_theme_initialize();
+  theme_initialize();
 
   if (!isset($theme)) {
     // If theme is not specifically set, rehash for the current theme.
@@ -41,7 +43,7 @@ function block_admin_display($theme = NULL) {
   // Fetch and sort blocks.
   $blocks = block_admin_display_prepare_blocks($theme);
 
-  return drupal_get_form('block_admin_display_form', $blocks, $theme);
+  return get_form('block_admin_display_form', $blocks, $theme);
 }
 
 /**
@@ -58,9 +60,9 @@ function block_admin_display($theme = NULL) {
  */
 function block_admin_display_prepare_blocks($theme) {
   $blocks = _block_rehash($theme);
-  $compare_theme = &drupal_static('_block_compare:theme');
+  $compare_theme = &drupal_static('Drupal\_block_compare:theme');
   $compare_theme = $theme;
-  usort($blocks, '_block_compare');
+  usort($blocks, 'Drupal\_block_compare');
   return $blocks;
 }
 
@@ -85,7 +87,7 @@ function block_admin_display_prepare_blocks($theme) {
  */
 function block_admin_display_form($form, &$form_state, $blocks, $theme, $block_regions = NULL) {
 
-  $form['#attached']['css'] = array(drupal_get_path('module', 'block') . '/block.admin.css');
+  $form['#attached']['css'] = array(get_path('module', 'block') . '/block.admin.css');
 
   // Get a list of block regions if one was not provided.
   if (!isset($block_regions)) {
@@ -200,7 +202,7 @@ function block_admin_display_form_submit($form, &$form_state) {
     watchdog_exception('block', $e);
     throw $e;
   }
-  drupal_set_message(t('The block settings have been updated.'));
+  set_message(t('The block settings have been updated.'));
   cache_clear_all();
 }
 
@@ -277,7 +279,7 @@ function block_admin_configure($form, &$form_state, $module, $delta) {
   // Get the block subject for the page title.
   $info = module_invoke($block->module, 'block_info');
   if (isset($info[$block->delta])) {
-    drupal_set_title(t("'%name' block", array('%name' => $info[$block->delta]['info'])), PASS_THROUGH);
+    set_title(t("'%name' block", array('%name' => $info[$block->delta]['info'])), PASS_THROUGH);
   }
 
   $form['settings']['title'] = array(
@@ -344,7 +346,7 @@ function block_admin_configure($form, &$form_state, $module, $delta) {
   $form['visibility'] = array(
     '#type' => 'vertical_tabs',
     '#attached' => array(
-      'js' => array(drupal_get_path('module', 'block') . '/block.js'),
+      'js' => array(get_path('module', 'block') . '/block.js'),
     ),
   );
 
@@ -403,7 +405,7 @@ function block_admin_configure($form, &$form_state, $module, $delta) {
     ':module' => $block->module,
     ':delta' => $block->delta,
   ))->fetchCol();
-  $role_options = array_map('check_plain', user_roles());
+  $role_options = array_map('Drupal\check_plain', user_roles());
   $form['visibility']['role'] = array(
     '#type' => 'fieldset',
     '#title' => t('Roles'),
@@ -522,7 +524,7 @@ function block_admin_configure_submit($form, &$form_state) {
       watchdog_exception('block', $e);
       throw $e;
     }
-    drupal_set_message(t('The block configuration has been saved.'));
+    set_message(t('The block configuration has been saved.'));
     cache_clear_all();
     $form_state['redirect'] = 'admin/structure/block';
   }
@@ -588,7 +590,7 @@ function block_add_block_form_submit($form, &$form_state) {
         'status' => 0,
         'weight' => 0,
         'delta' => $delta,
-        'cache' => DRUPAL_NO_CACHE,
+        'cache' => NO_CACHE,
       ));
     }
   }
@@ -616,7 +618,7 @@ function block_add_block_form_submit($form, &$form_state) {
       ->execute();
   }
 
-  drupal_set_message(t('The block has been created.'));
+  set_message(t('The block has been created.'));
   cache_clear_all();
   $form_state['redirect'] = 'admin/structure/block';
 }
@@ -661,7 +663,7 @@ function block_custom_block_delete_submit($form, &$form_state) {
     ->condition('module', 'block')
     ->condition('delta', $form_state['values']['bid'])
     ->execute();
-  drupal_set_message(t('The block %name has been removed.', array('%name' => $form_state['values']['info'])));
+  set_message(t('The block %name has been removed.', array('%name' => $form_state['values']['info'])));
   cache_clear_all();
   $form_state['redirect'] = 'admin/structure/block';
   return;
@@ -712,6 +714,6 @@ function template_preprocess_block_admin_display_form(&$variables) {
     $variables['block_listing'][$region][$i]->printed = FALSE;
   }
 
-  $variables['form_submit'] = drupal_render_children($variables['form']);
+  $variables['form_submit'] = render_children($variables['form']);
 }
 
diff --git a/core/modules/block/block.api.php b/core/modules/block/block.api.php
index d33f594..1d10518 100644
--- a/core/modules/block/block.api.php
+++ b/core/modules/block/block.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -45,17 +46,17 @@
  *   - 'cache': (optional) A bitmask describing what kind of caching is
  *     appropriate for the block. Drupal provides the following bitmask
  *     constants for defining cache granularity:
- *     - DRUPAL_CACHE_PER_ROLE (default): The block can change depending on the
+ *     - CACHE_PER_ROLE (default): The block can change depending on the
  *       roles the user viewing the page belongs to.
- *     - DRUPAL_CACHE_PER_USER: The block can change depending on the user
+ *     - CACHE_PER_USER: The block can change depending on the user
  *       viewing the page. This setting can be resource-consuming for sites
  *       with large number of users, and should only be used when
- *       DRUPAL_CACHE_PER_ROLE is not sufficient.
- *     - DRUPAL_CACHE_PER_PAGE: The block can change depending on the page
+ *       CACHE_PER_ROLE is not sufficient.
+ *     - CACHE_PER_PAGE: The block can change depending on the page
  *       being viewed.
- *     - DRUPAL_CACHE_GLOBAL: The block is the same for every user on every
+ *     - CACHE_GLOBAL: The block is the same for every user on every
  *       page where it is visible.
- *     - DRUPAL_NO_CACHE: The block should not get cached.
+ *     - NO_CACHE: The block should not get cached.
  *   - 'properties': (optional) Array of additional metadata to add to the
  *     block. Common properties include:
  *     - 'administrative': Boolean which categorizes this block as usable in
@@ -98,12 +99,12 @@ function hook_block_info() {
   // This example comes from node.module.
   $blocks['syndicate'] = array(
     'info' => t('Syndicate'),
-    'cache' => DRUPAL_NO_CACHE
+    'cache' => NO_CACHE
   );
 
   $blocks['recent'] = array(
     'info' => t('Recent content'),
-    // DRUPAL_CACHE_PER_ROLE will be assumed.
+    // CACHE_PER_ROLE will be assumed.
   );
 
   return $blocks;
@@ -154,7 +155,7 @@ function hook_block_configure($delta = '') {
       '#type' => 'select',
       '#title' => t('Number of recent content items to display'),
       '#default_value' => variable_get('node_recent_block_count', 10),
-      '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
+      '#options' => map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
     );
   }
   return $form;
diff --git a/core/modules/block/block.install b/core/modules/block/block.install
index c2d4185..4cc51ed 100644
--- a/core/modules/block/block.install
+++ b/core/modules/block/block.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -166,7 +167,7 @@ function block_schema() {
     'primary key' => array('bid'),
   );
 
-  $schema['cache_block'] = drupal_get_schema_unprocessed('system', 'cache');
+  $schema['cache_block'] = get_schema_unprocessed('system', 'cache');
   $schema['cache_block']['description'] = 'Cache table for the Block module to store already built blocks, identified by module, delta, and various contexts which may change the block, such as theme, locale, and caching mode defined for the block.';
 
   return $schema;
diff --git a/core/modules/block/block.module b/core/modules/block/block.module
index 4d942ed..414aeb0 100644
--- a/core/modules/block/block.module
+++ b/core/modules/block/block.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use PDO, stdClass;
 
 /**
  * @file
@@ -114,7 +116,7 @@ function block_menu() {
   );
   $items['admin/structure/block/manage/%/%'] = array(
     'title' => 'Configure block',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('block_admin_configure', 4, 5),
     'access arguments' => array('administer blocks'),
     'file' => 'block.admin.inc',
@@ -126,7 +128,7 @@ function block_menu() {
   );
   $items['admin/structure/block/manage/%/%/delete'] = array(
     'title' => 'Delete block',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('block_custom_block_delete', 4, 5),
     'access arguments' => array('administer blocks'),
     'type' => MENU_LOCAL_TASK,
@@ -135,7 +137,7 @@ function block_menu() {
   );
   $items['admin/structure/block/add'] = array(
     'title' => 'Add block',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('block_add_block_form'),
     'access arguments' => array('administer blocks'),
     'type' => MENU_LOCAL_ACTION,
@@ -154,7 +156,7 @@ function block_menu() {
     if ($key != $default_theme) {
       $items['admin/structure/block/list/' . $key . '/add'] = array(
         'title' => 'Add block',
-        'page callback' => 'drupal_get_form',
+        'page callback' => 'get_form',
         'page arguments' => array('block_add_block_form'),
         'access arguments' => array('administer blocks'),
         'type' => MENU_LOCAL_ACTION,
@@ -189,7 +191,7 @@ function block_menu() {
  * @see block_menu()
  */
 function _block_themes_access($theme) {
-  return user_access('administer blocks') && drupal_theme_access($theme);
+  return user_access('administer blocks') && theme_access($theme);
 }
 
 /**
@@ -223,7 +225,7 @@ function block_block_info() {
   foreach ($result as $block) {
     $blocks[$block->bid]['info'] = $block->info;
     // Not worth caching.
-    $blocks[$block->bid]['cache'] = DRUPAL_NO_CACHE;
+    $blocks[$block->bid]['cache'] = NO_CACHE;
   }
   return $blocks;
 }
@@ -269,7 +271,7 @@ function block_page_build(&$page) {
   global $theme;
 
   // The theme system might not yet be initialized. We need $theme.
-  drupal_theme_initialize();
+  theme_initialize();
 
   // Fetch a list of regions for the current theme.
   $all_regions = system_region_list($theme);
@@ -291,7 +293,7 @@ function block_page_build(&$page) {
     // actually built. We do not clear the cache any earlier than this, though,
     // because it is used each time block_get_blocks_by_region() gets called
     // above.
-    drupal_static_reset('block_list');
+    drupal_static_reset('Drupal\block_list');
   }
   else {
     // Append region description if we are rendering the regions demo page.
@@ -364,7 +366,7 @@ function _block_get_renderable_region($list = array()) {
       $GLOBALS['user']->uid == 1 ||
       count(module_implements('node_grants')) ||
       !in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) ||
-      in_array($block->cache, array(DRUPAL_NO_CACHE, DRUPAL_CACHE_CUSTOM))
+      in_array($block->cache, array(NO_CACHE, CACHE_CUSTOM))
     ) {
       // Non-cached blocks get built immediately. Provides more content
       // that can be easily manipulated during hook_page_alter().
@@ -408,7 +410,7 @@ function _block_get_renderable_region($list = array()) {
 function _block_rehash($theme = NULL) {
   global $theme_key;
 
-  drupal_theme_initialize();
+  theme_initialize();
   if (!isset($theme)) {
     // If theme is not specifically set, rehash for the current theme.
     $theme = $theme_key;
@@ -458,7 +460,7 @@ function _block_rehash($theme = NULL) {
     // Preserve this block.
     $bids[$block->bid] = $block->bid;
   }
-  drupal_alter('block_info', $current_blocks, $theme, $code_blocks);
+  alter('block_info', $current_blocks, $theme, $code_blocks);
   foreach ($current_blocks as $module => $module_blocks) {
     foreach ($module_blocks as $delta => $block) {
       if (!isset($block['pages'])) {
@@ -472,7 +474,7 @@ function _block_rehash($theme = NULL) {
         $block['weight'] = 0;
       }
       if (!empty($block['region']) && $block['region'] != BLOCK_REGION_NONE && !isset($regions[$block['region']])) {
-        drupal_set_message(t('The block %info was assigned to the invalid region %region and has been disabled.', array('%info' => $block['info'], '%region' => $block['region'])), 'warning');
+        set_message(t('The block %info was assigned to the invalid region %region and has been disabled.', array('%info' => $block['info'], '%region' => $block['region'])), 'warning');
         // Disabled modules are moved into the BLOCK_REGION_NONE later so no
         // need to move the bock to another region.
         $block['status'] = 0;
@@ -487,7 +489,7 @@ function _block_rehash($theme = NULL) {
       if (isset($block['bid'])) {
         // If the block has a bid property, it comes from the database and
         // the record needs to be updated, so set the primary key to 'bid'
-        // before passing to drupal_write_record().
+        // before passing to write_record().
         $primary_keys = array('bid');
         // Remove a block from the list of blocks to keep if it became disabled.
         unset($bids[$block['bid']]);
@@ -495,7 +497,7 @@ function _block_rehash($theme = NULL) {
       else {
         $primary_keys = array();
       }
-      drupal_write_record('block', $block, $primary_keys);
+      write_record('block', $block, $primary_keys);
       // Add to the list of blocks we return.
       $blocks[] = $block;
     }
@@ -675,7 +677,7 @@ function block_theme_initialize($theme) {
       }
       $block['theme'] = $theme;
       unset($block['bid']);
-      drupal_write_record('block', $block);
+      write_record('block', $block);
     }
   }
 }
@@ -763,7 +765,7 @@ function _block_load_blocks() {
 
   $block_info = $result->fetchAllAssoc('bid');
   // Allow modules to modify the block list.
-  drupal_alter('block_list', $block_info);
+  alter('block_list', $block_info);
 
   $blocks = array();
   foreach ($block_info as $block) {
@@ -833,11 +835,11 @@ function block_block_list_alter(&$blocks) {
       $pages = drupal_strtolower($block->pages);
       if ($block->visibility < BLOCK_VISIBILITY_PHP) {
         // Convert the Drupal path to lowercase
-        $path = drupal_strtolower(drupal_get_path_alias($_GET['q']));
+        $path = drupal_strtolower(get_path_alias($_GET['q']));
         // Compare the lowercase internal and lowercase path alias (if any).
-        $page_match = drupal_match_path($path, $pages);
+        $page_match = match_path($path, $pages);
         if ($path != $_GET['q']) {
-          $page_match = $page_match || drupal_match_path($_GET['q'], $pages);
+          $page_match = $page_match || match_path($_GET['q'], $pages);
         }
         // When $block->visibility has a value of 0 (BLOCK_VISIBILITY_NOTLISTED),
         // the block is displayed on all pages except those listed in $block->pages.
@@ -881,7 +883,7 @@ function _block_get_renderable_block($element) {
 
     // Allow modules to modify the block before it is viewed, via either
     // hook_block_view_alter() or hook_block_view_MODULE_DELTA_alter().
-    drupal_alter(array('block_view', "block_view_{$block->module}_{$block->delta}"), $array, $block);
+    alter(array('block_view', "block_view_{$block->module}_{$block->delta}"), $array, $block);
 
     if (empty($array['content'])) {
       // Blocks without content should emit no markup at all.
@@ -963,7 +965,7 @@ function template_preprocess_block(&$variables) {
   // Create the $content variable that templates expect.
   $variables['content'] = $variables['elements']['#children'];
 
-  $variables['classes_array'][] = drupal_html_class('block-' . $variables['block']->module);
+  $variables['classes_array'][] = html_class('block-' . $variables['block']->module);
 
   // Add default class for block content.
   $variables['content_attributes_array']['class'][] = 'content';
@@ -972,7 +974,7 @@ function template_preprocess_block(&$variables) {
   $variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->module;
   // Hyphens (-) and underscores (_) play a special role in theme suggestions.
   // Theme suggestions should only contain underscores, because within
-  // drupal_find_theme_templates(), underscores are converted to hyphens to
+  // find_theme_templates(), underscores are converted to hyphens to
   // match template file names, and then converted back to underscores to match
   // pre-processing and other function names. So if your theme suggestion
   // contains a hyphen, it will end up as an underscore after this conversion,
@@ -981,7 +983,7 @@ function template_preprocess_block(&$variables) {
   $variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->module . '__' . strtr($variables['block']->delta, '-', '_');
 
   // Create a valid HTML ID and make sure it is unique.
-  $variables['block_html_id'] = drupal_html_id('block-' . $variables['block']->module . '-' . $variables['block']->delta);
+  $variables['block_html_id'] = html_id('block-' . $variables['block']->module . '-' . $variables['block']->delta);
 }
 
 /**
diff --git a/core/modules/block/block.test b/core/modules/block/block.test
index dbd7dc4..1301833 100644
--- a/core/modules/block/block.test
+++ b/core/modules/block/block.test
@@ -1,11 +1,13 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
  * Tests for block.module.
  */
 
-class BlockTestCase extends DrupalWebTestCase {
+class BlockTestCase extends WebTestCase {
   protected $regions;
   protected $admin_user;
 
@@ -369,21 +371,21 @@ class BlockTestCase extends DrupalWebTestCase {
     // Our new block should be inserted in the database when we visit the
     // block management page.
     $this->drupalGet('admin/structure/block');
-    // Our test block's caching should default to DRUPAL_CACHE_PER_ROLE.
+    // Our test block's caching should default to CACHE_PER_ROLE.
     $current_caching = db_query("SELECT cache FROM {block} WHERE module = 'block_test' AND delta = 'test_cache'")->fetchField();
-    $this->assertEqual($current_caching, DRUPAL_CACHE_PER_ROLE, t('Test block cache mode defaults to DRUPAL_CACHE_PER_ROLE.'));
+    $this->assertEqual($current_caching, CACHE_PER_ROLE, t('Test block cache mode defaults to CACHE_PER_ROLE.'));
 
     // Disable caching for this block.
-    variable_set('block_test_caching', DRUPAL_NO_CACHE);
+    variable_set('block_test_caching', NO_CACHE);
     // Flushing all caches should call _block_rehash().
-    drupal_flush_all_caches();
+    flush_all_caches();
     // Verify that the database is updated with the new caching mode.
     $current_caching = db_query("SELECT cache FROM {block} WHERE module = 'block_test' AND delta = 'test_cache'")->fetchField();
-    $this->assertEqual($current_caching, DRUPAL_NO_CACHE, t("Test block's database entry updated to DRUPAL_NO_CACHE."));
+    $this->assertEqual($current_caching, NO_CACHE, t("Test block's database entry updated to NO_CACHE."));
   }
 }
 
-class NonDefaultBlockAdmin extends DrupalWebTestCase {
+class NonDefaultBlockAdmin extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Non default theme admin',
@@ -406,7 +408,7 @@ class NonDefaultBlockAdmin extends DrupalWebTestCase {
 /**
  * Test blocks correctly initialized when picking a new default theme.
  */
-class NewDefaultThemeBlocks extends DrupalWebTestCase {
+class NewDefaultThemeBlocks extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'New default theme blocks',
@@ -456,7 +458,7 @@ class NewDefaultThemeBlocks extends DrupalWebTestCase {
 /**
  * Test the block system with admin themes.
  */
-class BlockAdminThemeTestCase extends DrupalWebTestCase {
+class BlockAdminThemeTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Admin theme block admin accessibility',
@@ -488,7 +490,7 @@ class BlockAdminThemeTestCase extends DrupalWebTestCase {
 /**
  * Test block caching.
  */
-class BlockCacheTestCase extends DrupalWebTestCase {
+class BlockCacheTestCase extends WebTestCase {
   protected $admin_user;
   protected $normal_user;
   protected $normal_user_alt;
@@ -522,10 +524,10 @@ class BlockCacheTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Test DRUPAL_CACHE_PER_ROLE.
+   * Test CACHE_PER_ROLE.
    */
   function testCachePerRole() {
-    $this->setCacheMode(DRUPAL_CACHE_PER_ROLE);
+    $this->setCacheMode(CACHE_PER_ROLE);
 
     // Enable our test block. Set some content for it to display.
     $current_content = $this->randomName();
@@ -569,10 +571,10 @@ class BlockCacheTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Test DRUPAL_CACHE_GLOBAL.
+   * Test CACHE_GLOBAL.
    */
   function testCacheGlobal() {
-    $this->setCacheMode(DRUPAL_CACHE_GLOBAL);
+    $this->setCacheMode(CACHE_GLOBAL);
     $current_content = $this->randomName();
     variable_set('block_test_content', $current_content);
 
@@ -589,14 +591,14 @@ class BlockCacheTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Test DRUPAL_NO_CACHE.
+   * Test NO_CACHE.
    */
   function testNoCache() {
-    $this->setCacheMode(DRUPAL_NO_CACHE);
+    $this->setCacheMode(NO_CACHE);
     $current_content = $this->randomName();
     variable_set('block_test_content', $current_content);
 
-    // If DRUPAL_NO_CACHE has no effect, the next request would be cached.
+    // If NO_CACHE has no effect, the next request would be cached.
     $this->drupalGet('');
     $this->assertText($current_content, t('Block content displays.'));
 
@@ -604,14 +606,14 @@ class BlockCacheTestCase extends DrupalWebTestCase {
     $current_content = $this->randomName();
     variable_set('block_test_content', $current_content);
     $this->drupalGet('');
-    $this->assertText($current_content, t('DRUPAL_NO_CACHE prevents blocks from being cached.'));
+    $this->assertText($current_content, t('NO_CACHE prevents blocks from being cached.'));
   }
 
   /**
-   * Test DRUPAL_CACHE_PER_USER.
+   * Test CACHE_PER_USER.
    */
   function testCachePerUser() {
-    $this->setCacheMode(DRUPAL_CACHE_PER_USER);
+    $this->setCacheMode(CACHE_PER_USER);
     $current_content = $this->randomName();
     variable_set('block_test_content', $current_content);
     $this->drupalLogin($this->normal_user);
@@ -636,10 +638,10 @@ class BlockCacheTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Test DRUPAL_CACHE_PER_PAGE.
+   * Test CACHE_PER_PAGE.
    */
   function testCachePerPage() {
-    $this->setCacheMode(DRUPAL_CACHE_PER_PAGE);
+    $this->setCacheMode(CACHE_PER_PAGE);
     $current_content = $this->randomName();
     variable_set('block_test_content', $current_content);
 
@@ -675,7 +677,7 @@ class BlockCacheTestCase extends DrupalWebTestCase {
 /**
  * Test block HTML id validity.
  */
-class BlockHTMLIdTestCase extends DrupalWebTestCase {
+class BlockHTMLIdTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -714,7 +716,7 @@ class BlockHTMLIdTestCase extends DrupalWebTestCase {
 /**
  * Unit tests for template_preprocess_block().
  */
-class BlockTemplateSuggestionsUnitTest extends DrupalUnitTestCase {
+class BlockTemplateSuggestionsUnitTest extends UnitTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Block template suggestions',
@@ -759,7 +761,7 @@ class BlockTemplateSuggestionsUnitTest extends DrupalUnitTestCase {
 /**
  * Tests that hidden regions do not inherit blocks when a theme is enabled.
  */
-class BlockHiddenRegionTestCase extends DrupalWebTestCase {
+class BlockHiddenRegionTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Blocks not in hidden region',
diff --git a/core/modules/block/block.tpl.php b/core/modules/block/block.tpl.php
index 78387a8..3b67fb7 100644
--- a/core/modules/block/block.tpl.php
+++ b/core/modules/block/block.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/block/tests/block_test.module b/core/modules/block/tests/block_test.module
index 5e06d5c..715e796 100644
--- a/core/modules/block/tests/block_test.module
+++ b/core/modules/block/tests/block_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -9,7 +10,7 @@
  * Implements hook_system_theme_info().
  */
 function block_test_system_theme_info() {
-  $themes['block_test_theme'] = drupal_get_path('module', 'block_test') . '/themes/block_test_theme/block_test_theme.info';
+  $themes['block_test_theme'] = get_path('module', 'block_test') . '/themes/block_test_theme/block_test_theme.info';
   return $themes;
 }
 
@@ -19,7 +20,7 @@ function block_test_system_theme_info() {
 function block_test_block_info() {
   $blocks['test_cache'] = array(
     'info' => t('Test block caching'),
-    'cache' => variable_get('block_test_caching', DRUPAL_CACHE_PER_ROLE),
+    'cache' => variable_get('block_test_caching', CACHE_PER_ROLE),
   );
 
   $blocks['test_html_id'] = array(
diff --git a/core/modules/block/tests/themes/block_test_theme/page.tpl.php b/core/modules/block/tests/themes/block_test_theme/page.tpl.php
index ba72882..2eb0342 100644
--- a/core/modules/block/tests/themes/block_test_theme/page.tpl.php
+++ b/core/modules/block/tests/themes/block_test_theme/page.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/book/book-all-books-block.tpl.php b/core/modules/book/book-all-books-block.tpl.php
index 8e5343b..3ab640f 100644
--- a/core/modules/book/book-all-books-block.tpl.php
+++ b/core/modules/book/book-all-books-block.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/book/book-export-html.tpl.php b/core/modules/book/book-export-html.tpl.php
index df04dab..750ad56 100644
--- a/core/modules/book/book-export-html.tpl.php
+++ b/core/modules/book/book-export-html.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/book/book-navigation.tpl.php b/core/modules/book/book-navigation.tpl.php
index ed608f0..f5ac412 100644
--- a/core/modules/book/book-navigation.tpl.php
+++ b/core/modules/book/book-navigation.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 /**
  * @file
  * Default theme implementation to navigate books.
diff --git a/core/modules/book/book-node-export-html.tpl.php b/core/modules/book/book-node-export-html.tpl.php
index 0c2c67c..38ed51f 100644
--- a/core/modules/book/book-node-export-html.tpl.php
+++ b/core/modules/book/book-node-export-html.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/book/book.admin.inc b/core/modules/book/book.admin.inc
index e37c7fc..6def565 100644
--- a/core/modules/book/book.admin.inc
+++ b/core/modules/book/book.admin.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -81,7 +82,7 @@ function book_admin_settings_validate($form, &$form_state) {
  * @ingroup forms
  */
 function book_admin_edit($form, $form_state, $node) {
-  drupal_set_title($node->title);
+  set_title($node->title);
   $form['#node'] = $node;
   _book_admin_table($node, $form);
   $form['save'] = array(
@@ -147,7 +148,7 @@ function book_admin_edit_submit($form, &$form_state) {
     }
   }
 
-  drupal_set_message(t('Updated book %title.', array('%title' => $form['#node']->title)));
+  set_message(t('Updated book %title.', array('%title' => $form['#node']->title)));
 }
 
 /**
@@ -169,7 +170,7 @@ function _book_admin_table($node, &$form) {
   $tree = book_menu_subtree_data($node->book);
   $tree = array_shift($tree); // Do not include the book item itself.
   if ($tree['below']) {
-    $hash = drupal_hash_base64(serialize($tree['below']));
+    $hash = hash_base64(serialize($tree['below']));
     // Store the hash value as a hidden form element so that we can detect
     // if another user changed the book hierarchy.
     $form['tree_hash'] = array(
@@ -252,13 +253,13 @@ function _book_admin_table_tree($tree, &$form) {
 function theme_book_admin_table($variables) {
   $form = $variables['form'];
 
-  drupal_add_tabledrag('book-outline', 'match', 'parent', 'book-plid', 'book-plid', 'book-mlid', TRUE, MENU_MAX_DEPTH - 2);
-  drupal_add_tabledrag('book-outline', 'order', 'sibling', 'book-weight');
+  add_tabledrag('book-outline', 'match', 'parent', 'book-plid', 'book-plid', 'book-mlid', TRUE, MENU_MAX_DEPTH - 2);
+  add_tabledrag('book-outline', 'order', 'sibling', 'book-weight');
 
   $header = array(t('Title'), t('Weight'), t('Parent'), array('data' => t('Operations'), 'colspan' => '3'));
 
   $rows = array();
-  $destination = drupal_get_destination();
+  $destination = get_destination();
   $access = user_access('administer nodes');
   foreach (element_children($form) as $key) {
     $nid = $form[$key]['nid']['#value'];
diff --git a/core/modules/book/book.install b/core/modules/book/book.install
index 899ee81..24e88c9 100644
--- a/core/modules/book/book.install
+++ b/core/modules/book/book.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/book/book.module b/core/modules/book/book.module
index a6c1886..bd6d220 100644
--- a/core/modules/book/book.module
+++ b/core/modules/book/book.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use PDO;
 
 /**
  * @file
@@ -142,7 +144,7 @@ function book_menu() {
   );
   $items['admin/content/book/settings'] = array(
     'title' => 'Settings',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('book_admin_settings'),
     'access arguments' => array('administer site configuration'),
     'type' => MENU_LOCAL_TASK,
@@ -151,7 +153,7 @@ function book_menu() {
   );
   $items['admin/content/book/%node'] = array(
     'title' => 'Re-order book pages and change titles',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('book_admin_edit', 3),
     'access callback' => '_book_outline_access',
     'access arguments' => array(3),
@@ -184,7 +186,7 @@ function book_menu() {
   );
   $items['node/%node/outline/remove'] = array(
     'title' => 'Remove from outline',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('book_remove_form', 1),
     'access callback' => '_book_outline_remove_access',
     'access arguments' => array(1),
@@ -256,7 +258,7 @@ function book_entity_info_alter(&$info) {
 function book_block_info() {
   $block = array();
   $block['navigation']['info'] = t('Book navigation');
-  $block['navigation']['cache'] = DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE;
+  $block['navigation']['cache'] = CACHE_PER_PAGE | CACHE_PER_ROLE;
 
   return $block;
 }
@@ -433,7 +435,7 @@ function book_form_node_form_alter(&$form, &$form_state, $form_id) {
       '#submit' => array('book_pick_book_nojs_submit'),
       '#weight' => 20,
       '#attached' => array(
-        'css' => array(drupal_get_path('module', 'book') . '/book.admin.css'),
+        'css' => array(get_path('module', 'book') . '/book.admin.css'),
       ),
     );
   }
@@ -533,7 +535,7 @@ function _book_add_form_elements(&$form, &$form_state, $node) {
       'class' => array('book-form'),
     ),
     '#attached' => array(
-      'js' => array(drupal_get_path('module', 'book') . '/book.js'),
+      'js' => array(get_path('module', 'book') . '/book.js'),
     ),
     '#tree' => TRUE,
     '#attributes' => array('class' => array('book-outline-form')),
@@ -663,7 +665,7 @@ function _book_update_outline($node) {
         ))
         ->execute();
       // Reset the cache of stored books.
-      drupal_static_reset('book_get_books');
+      drupal_static_reset('Drupal\book_get_books');
     }
     else {
       if ($node->book['bid'] != db_query("SELECT bid FROM {book} WHERE nid = :nid", array(
@@ -672,7 +674,7 @@ function _book_update_outline($node) {
         // Update the bid for this page and all children.
         book_update_bid($node->book);
         // Reset the cache of stored books.
-        drupal_static_reset('book_get_books');
+        drupal_static_reset('Drupal\book_get_books');
       }
     }
 
@@ -978,7 +980,7 @@ function book_node_predelete($node) {
     db_delete('book')
       ->condition('mlid', $node->book['mlid'])
       ->execute();
-    drupal_static_reset('book_get_books');
+    drupal_static_reset('Drupal\book_get_books');
   }
 }
 
@@ -1111,21 +1113,21 @@ function template_preprocess_book_navigation(&$variables) {
 
     if ($prev = book_prev($book_link)) {
       $prev_href = url($prev['href']);
-      drupal_add_html_head_link(array('rel' => 'prev', 'href' => $prev_href));
+      add_html_head_link(array('rel' => 'prev', 'href' => $prev_href));
       $variables['prev_url'] = $prev_href;
       $variables['prev_title'] = check_plain($prev['title']);
     }
 
     if ($book_link['plid'] && $parent = book_link_load($book_link['plid'])) {
       $parent_href = url($parent['href']);
-      drupal_add_html_head_link(array('rel' => 'up', 'href' => $parent_href));
+      add_html_head_link(array('rel' => 'up', 'href' => $parent_href));
       $variables['parent_url'] = $parent_href;
       $variables['parent_title'] = check_plain($parent['title']);
     }
 
     if ($next = book_next($book_link)) {
       $next_href = url($next['href']);
-      drupal_add_html_head_link(array('rel' => 'next', 'href' => $next_href));
+      add_html_head_link(array('rel' => 'next', 'href' => $next_href));
       $variables['next_url'] = $next_href;
       $variables['next_title'] = check_plain($next['title']);
     }
@@ -1224,7 +1226,7 @@ function template_preprocess_book_export_html(&$variables) {
   $variables['base_url'] = $base_url;
   $variables['language'] = $language;
   $variables['language_rtl'] = ($language->direction == LANGUAGE_RTL);
-  $variables['head'] = drupal_get_html_head();
+  $variables['head'] = get_html_head();
 
   // HTML element attributes.
   $variables['html_attributes_array']['lang'] = $language->langcode;
@@ -1238,7 +1240,7 @@ function template_preprocess_book_export_html(&$variables) {
  */
 function template_process_book_export_html(&$variables) {
   // Flatten out html_attributes
-  $variables['html_attributes'] = drupal_attributes($variables['html_attributes_array']);
+  $variables['html_attributes'] = attributes($variables['html_attributes_array']);
 }
 
 /**
@@ -1268,7 +1270,7 @@ function book_export_traverse($tree, $visit_func) {
       }
 
       if (!empty($visit_func)) {
-        $output .= call_user_func($visit_func, $node, $children);
+        $output .= call_user_func('Drupal\\' . $visit_func, $node, $children);
       }
       else {
         // Use the default function.
diff --git a/core/modules/book/book.pages.inc b/core/modules/book/book.pages.inc
index e5f0832..48ac170 100644
--- a/core/modules/book/book.pages.inc
+++ b/core/modules/book/book.pages.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -48,14 +49,14 @@ function book_render() {
 function book_export($type, $nid) {
   $type = drupal_strtolower($type);
 
-  $export_function = 'book_export_' . $type;
+  $export_function = 'Drupal\book_export_' . $type;
 
   if (function_exists($export_function)) {
     print call_user_func($export_function, $nid);
   }
   else {
-    drupal_set_message(t('Unknown export format.'));
-    drupal_not_found();
+    set_message(t('Unknown export format.'));
+    not_found();
   }
 }
 
@@ -86,11 +87,11 @@ function book_export_html($nid) {
       return theme('book_export_html', array('title' => $node->title, 'contents' => $contents, 'depth' => $node->book['depth']));
     }
     else {
-      drupal_not_found();
+      not_found();
     }
   }
   else {
-    drupal_access_denied();
+    access_denied();
   }
 }
 
@@ -105,8 +106,8 @@ function book_export_html($nid) {
  * @see book_menu()
  */
 function book_outline($node) {
-  drupal_set_title($node->title);
-  return drupal_get_form('book_outline_form', $node);
+  set_title($node->title);
+  return get_form('book_outline_form', $node);
 }
 
 /**
@@ -178,7 +179,7 @@ function book_outline_form_submit($form, &$form_state) {
   $form_state['redirect'] = "node/" . $node->nid;
   $book_link = $form_state['values']['book'];
   if (!$book_link['bid']) {
-    drupal_set_message(t('No changes were made'));
+    set_message(t('No changes were made'));
 
     return;
   }
@@ -188,15 +189,15 @@ function book_outline_form_submit($form, &$form_state) {
   if (_book_update_outline($node)) {
     if ($node->book['parent_mismatch']) {
       // This will usually only happen when JS is disabled.
-      drupal_set_message(t('The post has been added to the selected book. You may now position it relative to other pages.'));
+      set_message(t('The post has been added to the selected book. You may now position it relative to other pages.'));
       $form_state['redirect'] = "node/" . $node->nid . "/outline";
     }
     else {
-      drupal_set_message(t('The book outline has been updated.'));
+      set_message(t('The book outline has been updated.'));
     }
   }
   else {
-    drupal_set_message(t('There was an error adding the post to the book.'), 'error');
+    set_message(t('There was an error adding the post to the book.'), 'error');
   }
 }
 
@@ -237,7 +238,7 @@ function book_remove_form_submit($form, &$form_state) {
     db_delete('book')
       ->condition('nid', $node->nid)
       ->execute();
-    drupal_set_message(t('The post has been removed from the book.'));
+    set_message(t('The post has been removed from the book.'));
   }
   $form_state['redirect'] = 'node/' . $node->nid;
 }
diff --git a/core/modules/book/book.test b/core/modules/book/book.test
index 83328e0..6025aa6 100644
--- a/core/modules/book/book.test
+++ b/core/modules/book/book.test
@@ -1,11 +1,12 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
  * Tests for book.module.
  */
 
-class BookTestCase extends DrupalWebTestCase {
+class BookTestCase extends WebTestCase {
   protected $book;
   // $book_author is a user with permission to create and edit books.
   protected $book_author;
diff --git a/core/modules/color/color.install b/core/modules/color/color.install
index a1879f9..a4c4f0a 100644
--- a/core/modules/color/color.install
+++ b/core/modules/color/color.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/color/color.module b/core/modules/color/color.module
index 401cbc9..69b47f4 100644
--- a/core/modules/color/color.module
+++ b/core/modules/color/color.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 /**
  * @file
  * Allows users to change the color scheme of themes.
@@ -96,7 +97,7 @@ function _color_html_alter(&$vars) {
       foreach ($color_paths as $color_path) {
         // Color module currently requires unique file names to be used,
         // which allows us to compare different file paths.
-        if (drupal_basename($old_path) == drupal_basename($color_path)) {
+        if (basename($old_path) == basename($color_path)) {
           // Replace the path to the new css file.
           // This keeps the order of the stylesheets intact.
           $vars['css'][$old_path]['data'] = $color_path;
@@ -104,7 +105,7 @@ function _color_html_alter(&$vars) {
       }
     }
 
-    $vars['styles'] = drupal_get_css($vars['css']);
+    $vars['styles'] = get_css($vars['css']);
   }
 }
 
@@ -137,8 +138,8 @@ function color_get_info($theme) {
     return $theme_info[$theme];
   }
 
-  $path = drupal_get_path('theme', $theme);
-  $file = DRUPAL_ROOT . '/' . $path . '/color/color.inc';
+  $path = get_path('theme', $theme);
+  $file = ROOT . '/' . $path . '/color/color.inc';
   if ($path && file_exists($file)) {
     include $file;
     $theme_info[$theme] = $info;
@@ -169,7 +170,7 @@ function color_get_palette($theme, $default = FALSE) {
  * @ingroup forms
  */
 function color_scheme_form($complete_form, &$form_state, $theme) {
-  $base = drupal_get_path('module', 'color');
+  $base = get_path('module', 'color');
   $info = color_get_info($theme);
 
   $info['schemes'][''] = array('title' => t('Custom'), 'colors' => array());
@@ -265,12 +266,12 @@ function theme_color_scheme_form($variables) {
 
   $theme = $form['theme']['#value'];
   $info = $form['info']['#value'];
-  $path = drupal_get_path('theme', $theme) . '/';
-  drupal_add_css($path . $info['preview_css']);
+  $path = get_path('theme', $theme) . '/';
+  add_css($path . $info['preview_css']);
 
-  $preview_js_path = isset($info['preview_js']) ? $path . $info['preview_js'] : drupal_get_path('module', 'color') . '/' . 'preview.js';
+  $preview_js_path = isset($info['preview_js']) ? $path . $info['preview_js'] : get_path('module', 'color') . '/' . 'preview.js';
   // Add the JS at a weight below color.js.
-  drupal_add_js($preview_js_path, array('weight' => -1));
+  add_js($preview_js_path, array('weight' => -1));
 
   $output  = '';
   $output .= '<div class="color-form clearfix">';
@@ -283,10 +284,10 @@ function theme_color_scheme_form($variables) {
   }
   $output .= '</div>';
   // Preview
-  $output .= drupal_render_children($form);
+  $output .= render_children($form);
   $output .= '<h2>' . t('Preview') . '</h2>';
   // Attempt to load preview HTML if the theme provides it.
-  $preview_html_path = DRUPAL_ROOT . '/' . (isset($info['preview_html']) ? drupal_get_path('theme', $theme) . '/' . $info['preview_html'] : drupal_get_path('module', 'color') . '/preview.html');
+  $preview_html_path = ROOT . '/' . (isset($info['preview_html']) ? get_path('theme', $theme) . '/' . $info['preview_html'] : get_path('module', 'color') . '/preview.html');
   $output .= file_get_contents($preview_html_path);
   // Close the wrapper div.
   $output .= '</div>';
@@ -335,7 +336,7 @@ function color_scheme_form_submit($form, &$form_state) {
   // Make sure enough memory is available, if PHP's memory limit is compiled in.
   if (function_exists('memory_get_usage')) {
     // Fetch source image dimensions.
-    $source = drupal_get_path('theme', $theme) . '/' . $info['base_image'];
+    $source = get_path('theme', $theme) . '/' . $info['base_image'];
     list($width, $height) = getimagesize($source);
 
     // We need at least a copy of the source and a target buffer of the same
@@ -348,7 +349,7 @@ function color_scheme_form_submit($form, &$form_state) {
     $usage = memory_get_usage(TRUE);
     $limit = parse_size(ini_get('memory_limit'));
     if ($usage + $required > $limit) {
-      drupal_set_message(t('There is not enough memory available to PHP to change this theme\'s color scheme. You need at least %size more. Check the <a href="@url">PHP documentation</a> for more information.', array('%size' => format_size($usage + $required - $limit), '@url' => 'http://www.php.net/manual/ini.core.php#ini.sect.resource-limits')), 'error');
+      set_message(t('There is not enough memory available to PHP to change this theme\'s color scheme. You need at least %size more. Check the <a href="@url">PHP documentation</a> for more information.', array('%size' => format_size($usage + $required - $limit), '@url' => 'http://www.php.net/manual/ini.core.php#ini.sect.resource-limits')), 'error');
       return;
     }
   }
@@ -380,7 +381,7 @@ function color_scheme_form_submit($form, &$form_state) {
   }
   $paths['target'] = $paths['target'] . '/';
   $paths['id'] = $id;
-  $paths['source'] = drupal_get_path('theme', $theme) . '/';
+  $paths['source'] = get_path('theme', $theme) . '/';
   $paths['files'] = $paths['map'] = array();
 
   // Save palette and logo location.
@@ -389,7 +390,7 @@ function color_scheme_form_submit($form, &$form_state) {
 
   // Copy over neutral images.
   foreach ($info['copy'] as $file) {
-    $base = drupal_basename($file);
+    $base = basename($file);
     $source = $paths['source'] . $file;
     $filepath = file_unmanaged_copy($source, $paths['target'] . $base);
     $paths['map'][$file] = $base;
@@ -418,20 +419,20 @@ function color_scheme_form_submit($form, &$form_state) {
     foreach ($files as $file) {
       // Aggregate @imports recursively for each configured top level CSS file
       // without optimization. Aggregation and optimization will be
-      // handled by drupal_build_css_cache() only.
-      $style = drupal_load_stylesheet($paths['source'] . $file, FALSE);
+      // handled by build_css_cache() only.
+      $style = load_stylesheet($paths['source'] . $file, FALSE);
 
       // Return the path to where this CSS file originated from, stripping
       // off the name of the file at the end of the path.
       $base = base_path() . dirname($paths['source'] . $file) . '/';
-      _drupal_build_css_path(NULL, $base);
+      _build_css_path(NULL, $base);
 
       // Prefix all paths within this CSS file, ignoring absolute paths.
-      $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', '_drupal_build_css_path', $style);
+      $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', 'Drupal\_build_css_path', $style);
 
       // Rewrite stylesheet with new colors.
       $style = _color_rewrite_stylesheet($theme, $info, $paths, $palette, $style);
-      $base_file = drupal_basename($file);
+      $base_file = basename($file);
       $css[] = $paths['target'] . $base_file;
       _color_save_stylesheet($paths['target'] . $base_file, $style, $paths);
     }
@@ -571,7 +572,7 @@ function _color_render_images($theme, &$info, &$paths, $palette) {
   // Cut out slices.
   foreach ($info['slices'] as $file => $coord) {
     list($x, $y, $width, $height) = $coord;
-    $base = drupal_basename($file);
+    $base = basename($file);
     $image = drupal_realpath($paths['target'] . $base);
 
     // Cut out slice.
diff --git a/core/modules/color/color.test b/core/modules/color/color.test
index 06e4cb9..b56ed97 100644
--- a/core/modules/color/color.test
+++ b/core/modules/color/color.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -8,7 +9,7 @@
 /**
  * Tests the Color module functionality.
  */
-class ColorTestCase extends DrupalWebTestCase {
+class ColorTestCase extends WebTestCase {
   protected $big_user;
   protected $themes;
   protected $colorTests;
diff --git a/core/modules/comment/comment-wrapper.tpl.php b/core/modules/comment/comment-wrapper.tpl.php
index 5e58a67..1c7102c 100644
--- a/core/modules/comment/comment-wrapper.tpl.php
+++ b/core/modules/comment/comment-wrapper.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc
index 550de56..8dd51f4 100644
--- a/core/modules/comment/comment.admin.inc
+++ b/core/modules/comment/comment.admin.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -21,10 +22,10 @@ function comment_admin($type = 'new') {
   $edit = $_POST;
 
   if (isset($edit['operation']) && ($edit['operation'] == 'delete') && isset($edit['comments']) && $edit['comments']) {
-    return drupal_get_form('comment_multiple_delete_confirm');
+    return get_form('comment_multiple_delete_confirm');
   }
   else {
-    return drupal_get_form('comment_admin_overview', $type);
+    return get_form('comment_admin_overview', $type);
   }
 }
 
@@ -101,7 +102,7 @@ function comment_admin_overview($form, &$form_state, $arg) {
 
   // Build a table listing the appropriate comments.
   $options = array();
-  $destination = drupal_get_destination();
+  $destination = get_destination();
 
   foreach ($comments as $comment) {
     // Remove the first node title from the node_titles array and attach to
@@ -189,7 +190,7 @@ function comment_admin_overview_submit($form, &$form_state) {
       comment_save($comment);
     }
   }
-  drupal_set_message(t('The update has been performed.'));
+  set_message(t('The update has been performed.'));
   $form_state['redirect'] = 'admin/content/comment';
   cache_clear_all();
 }
@@ -222,8 +223,8 @@ function comment_multiple_delete_confirm($form, &$form_state) {
   $form['operation'] = array('#type' => 'hidden', '#value' => 'delete');
 
   if (!$comment_counter) {
-    drupal_set_message(t('There do not appear to be any comments to delete, or your selected comment was deleted by another administrator.'));
-    drupal_goto('admin/content/comment');
+    set_message(t('There do not appear to be any comments to delete, or your selected comment was deleted by another administrator.'));
+    redirect('admin/content/comment');
   }
   else {
     return confirm_form($form,
@@ -242,7 +243,7 @@ function comment_multiple_delete_confirm_submit($form, &$form_state) {
     cache_clear_all();
     $count = count($form_state['values']['comments']);
     watchdog('content', 'Deleted @count comments.', array('@count' => $count));
-    drupal_set_message(format_plural($count, 'Deleted 1 comment.', 'Deleted @count comments.'));
+    set_message(format_plural($count, 'Deleted 1 comment.', 'Deleted @count comments.'));
   }
   $form_state['redirect'] = 'admin/content/comment';
 }
@@ -260,7 +261,7 @@ function comment_multiple_delete_confirm_submit($form, &$form_state) {
  */
 function comment_confirm_delete_page($cid) {
   if ($comment = comment_load($cid)) {
-    return drupal_get_form('comment_confirm_delete', $comment);
+    return get_form('comment_confirm_delete', $comment);
   }
   return MENU_NOT_FOUND;
 }
@@ -297,7 +298,7 @@ function comment_confirm_delete_submit($form, &$form_state) {
   $comment = $form['#comment'];
   // Delete the comment and its replies.
   comment_delete($comment->cid);
-  drupal_set_message(t('The comment and all its replies have been deleted.'));
+  set_message(t('The comment and all its replies have been deleted.'));
   watchdog('content', 'Deleted comment @cid and its replies.', array('@cid' => $comment->cid));
   // Clear the cache so an anonymous user sees that his comment was deleted.
   cache_clear_all();
diff --git a/core/modules/comment/comment.api.php b/core/modules/comment/comment.api.php
index f270aad..6dbe1d6 100644
--- a/core/modules/comment/comment.api.php
+++ b/core/modules/comment/comment.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -112,7 +113,7 @@ function hook_comment_view_alter(&$build) {
  *   The comment the action is being performed on.
  */
 function hook_comment_publish($comment) {
-  drupal_set_message(t('Comment: @subject has been published', array('@subject' => $comment->subject)));
+  set_message(t('Comment: @subject has been published', array('@subject' => $comment->subject)));
 }
 
 /**
@@ -122,7 +123,7 @@ function hook_comment_publish($comment) {
  *   The comment the action is being performed on.
  */
 function hook_comment_unpublish($comment) {
-  drupal_set_message(t('Comment: @subject has been unpublished', array('@subject' => $comment->subject)));
+  set_message(t('Comment: @subject has been unpublished', array('@subject' => $comment->subject)));
 }
 
 /**
@@ -161,7 +162,7 @@ function hook_comment_predelete($comment) {
  * @see entity_delete_multiple()
  */
 function hook_comment_delete($comment) {
-  drupal_set_message(t('Comment: @subject has been deleted', array('@subject' => $comment->subject)));
+  set_message(t('Comment: @subject has been deleted', array('@subject' => $comment->subject)));
 }
 
 /**
diff --git a/core/modules/comment/comment.entity.inc b/core/modules/comment/comment.entity.inc
index 8db4167..3ddc347 100644
--- a/core/modules/comment/comment.entity.inc
+++ b/core/modules/comment/comment.entity.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install
index b71688a..5411db5 100644
--- a/core/modules/comment/comment.install
+++ b/core/modules/comment/comment.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 7ad14e8..604d093 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -448,7 +449,7 @@ function comment_block_configure($delta = '') {
     '#type' => 'select',
     '#title' => t('Number of recent comments'),
     '#default_value' => variable_get('comment_block_count', 10),
-    '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
+    '#options' => map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
   );
 
   return $form;
@@ -506,7 +507,7 @@ function comment_permalink($cid) {
     // Return the node view, this will show the correct comment in context.
     return menu_execute_active_handler('node/' . $node->nid, FALSE);
   }
-  drupal_not_found();
+  not_found();
 }
 
 /**
@@ -761,7 +762,7 @@ function comment_node_page_additions($node) {
   // Append comment form if needed.
   if (user_access('post comments') && $node->comment == COMMENT_NODE_OPEN && (variable_get('comment_form_location_' . $node->type, COMMENT_FORM_BELOW) == COMMENT_FORM_BELOW)) {
     $comment = entity_create('comment', array('nid' => $node->nid));
-    $additions['comment_form'] = drupal_get_form("comment_node_{$node->type}_form", $comment);
+    $additions['comment_form'] = get_form("comment_node_{$node->type}_form", $comment);
   }
 
   if ($additions) {
@@ -989,7 +990,7 @@ function comment_view($comment, $node, $view_mode = 'full', $langcode = NULL) {
 
   // Allow modules to modify the structured comment.
   $type = 'comment';
-  drupal_alter(array('comment_view', 'entity_view'), $build, $type);
+  alter(array('comment_view', 'entity_view'), $build, $type);
 
   return $build;
 }
@@ -1025,7 +1026,7 @@ function comment_build_content($comment, $node, $view_mode = 'full', $langcode =
 
   $comment->content['links'] = array(
     '#theme' => 'links__comment',
-    '#pre_render' => array('drupal_pre_render_links'),
+    '#pre_render' => array('pre_render_links'),
     '#attributes' => array('class' => array('links', 'inline')),
   );
   if (empty($comment->in_preview)) {
@@ -1076,7 +1077,7 @@ function comment_links($comment, $node) {
           'title' => t('approve'),
           'href' => "comment/$comment->cid/approve",
           'html' => TRUE,
-          'query' => array('token' => drupal_get_token("comment/$comment->cid/approve")),
+          'query' => array('token' => get_token("comment/$comment->cid/approve")),
         );
       }
     }
@@ -1152,7 +1153,7 @@ function comment_form_node_type_form_alter(&$form, $form_state) {
         'class' => array('comment-node-type-settings-form'),
       ),
       '#attached' => array(
-        'js' => array(drupal_get_path('module', 'comment') . '/comment-node-form.js'),
+        'js' => array(get_path('module', 'comment') . '/comment-node-form.js'),
       ),
     );
     // Unlike coment_form_node_form_alter(), all of these settings are applied
@@ -1189,7 +1190,7 @@ function comment_form_node_type_form_alter(&$form, $form_state) {
         COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
         COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information'),
       ),
-      '#access' => user_access('post comments', drupal_anonymous_user()),
+      '#access' => user_access('post comments', anonymous_user()),
     );
     $form['comment']['comment_subject_field'] = array(
       '#type' => 'checkbox',
@@ -1204,11 +1205,11 @@ function comment_form_node_type_form_alter(&$form, $form_state) {
     $form['comment']['comment_preview'] = array(
       '#type' => 'radios',
       '#title' => t('Preview comment'),
-      '#default_value' => variable_get('comment_preview_' . $form['#node_type']->type, DRUPAL_OPTIONAL),
+      '#default_value' => variable_get('comment_preview_' . $form['#node_type']->type, OPTIONAL),
       '#options' => array(
-        DRUPAL_DISABLED => t('Disabled'),
-        DRUPAL_OPTIONAL => t('Optional'),
-        DRUPAL_REQUIRED => t('Required'),
+        DISABLED => t('Disabled'),
+        OPTIONAL => t('Optional'),
+        REQUIRED => t('Required'),
       ),
     );
   }
@@ -1230,7 +1231,7 @@ function comment_form_node_form_alter(&$form, $form_state) {
       'class' => array('comment-node-settings-form'),
     ),
     '#attached' => array(
-      'js' => array(drupal_get_path('module', 'comment') . '/comment-node-form.js'),
+      'js' => array(get_path('module', 'comment') . '/comment-node-form.js'),
      ),
     '#weight' => 30,
   );
@@ -1359,7 +1360,7 @@ function comment_node_update_index($node) {
     // not view comments.
     $index_comments = TRUE;
     foreach ($perms['search content'] as $rid) {
-      if (!isset($perms['access comments'][$rid]) && ($rid <= DRUPAL_AUTHENTICATED_RID || !isset($perms['access comments'][DRUPAL_AUTHENTICATED_RID]))) {
+      if (!isset($perms['access comments'][$rid]) && ($rid <= AUTHENTICATED_RID || !isset($perms['access comments'][AUTHENTICATED_RID]))) {
         $index_comments = FALSE;
         break;
       }
@@ -1647,9 +1648,9 @@ function comment_get_display_page($cid, $node_type) {
  * @see comment_menu()
  */
 function comment_edit_page($comment) {
-  drupal_set_title(t('Edit comment %comment', array('%comment' => $comment->subject)), PASS_THROUGH);
+  set_title(t('Edit comment %comment', array('%comment' => $comment->subject)), PASS_THROUGH);
   $node = node_load($comment->nid);
-  return drupal_get_form("comment_node_{$node->type}_form", $comment);
+  return get_form("comment_node_{$node->type}_form", $comment);
 }
 
 /**
@@ -1688,7 +1689,7 @@ function comment_form($form, &$form_state, $comment) {
   $form['#node'] = $node;
 
   // Use #comment-form as unique jump target, regardless of node type.
-  $form['#id'] = drupal_html_id('comment_form');
+  $form['#id'] = html_id('comment_form');
   $form['#theme'] = array('comment_form__node_' . $node->type, 'comment_form');
 
   $anonymous_contact = variable_get('comment_anonymous_' . $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT);
@@ -1844,13 +1845,13 @@ function comment_form($form, &$form_state, $comment) {
   $form['actions']['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Save'),
-    '#access' => ($comment->cid && user_access('administer comments')) || variable_get('comment_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_REQUIRED || isset($form_state['comment_preview']),
+    '#access' => ($comment->cid && user_access('administer comments')) || variable_get('comment_preview_' . $node->type, OPTIONAL) != REQUIRED || isset($form_state['comment_preview']),
     '#weight' => 19,
   );
   $form['actions']['preview'] = array(
     '#type' => 'submit',
     '#value' => t('Preview'),
-    '#access' => (variable_get('comment_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_DISABLED),
+    '#access' => (variable_get('comment_preview_' . $node->type, OPTIONAL) != DISABLED),
     '#weight' => 20,
     '#submit' => array('comment_form_build_preview'),
   );
@@ -1879,7 +1880,7 @@ function comment_form_build_preview($form, &$form_state) {
 function comment_preview($comment) {
   global $user;
 
-  drupal_set_title(t('Preview comment'), PASS_THROUGH);
+  set_title(t('Preview comment'), PASS_THROUGH);
 
   $node = node_load($comment->nid);
 
@@ -2062,11 +2063,11 @@ function comment_form_submit($form, &$form_state) {
     // Explain the approval queue if necessary.
     if ($comment->status == COMMENT_NOT_PUBLISHED) {
       if (!user_access('administer comments')) {
-        drupal_set_message(t('Your comment has been queued for review by site administrators and will be published after approval.'));
+        set_message(t('Your comment has been queued for review by site administrators and will be published after approval.'));
       }
     }
     else {
-      drupal_set_message(t('Your comment has been posted.'));
+      set_message(t('Your comment has been posted.'));
     }
     $query = array();
     // Find the current display page for this comment.
@@ -2079,7 +2080,7 @@ function comment_form_submit($form, &$form_state) {
   }
   else {
     watchdog('content', 'Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->subject), WATCHDOG_WARNING);
-    drupal_set_message(t('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->subject)), 'error');
+    set_message(t('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->subject)), 'error');
     // Redirect the user to the node they are commenting on.
     $redirect = 'node/' . $node->nid;
   }
@@ -2181,11 +2182,11 @@ function theme_comment_post_forbidden($variables) {
       // We only output a link if we are certain that users will get permission
       // to post comments by logging in.
       $comment_roles = user_roles(TRUE, 'post comments');
-      $authenticated_post_comments = isset($comment_roles[DRUPAL_AUTHENTICATED_RID]);
+      $authenticated_post_comments = isset($comment_roles[AUTHENTICATED_RID]);
     }
 
     if ($authenticated_post_comments) {
-      // We cannot use drupal_get_destination() because these links
+      // We cannot use get_destination() because these links
       // sometimes appear on /node and taxonomy listing pages.
       if (variable_get('comment_form_location_' . $node->type, COMMENT_FORM_BELOW) == COMMENT_FORM_SEPARATE_PAGE) {
         $destination = array('destination' => "comment/reply/$node->nid#comment-form");
@@ -2237,7 +2238,7 @@ function _comment_get_modes() {
  * Returns an array of "comments per page" values that users can select from.
  */
 function _comment_per_page() {
-  return drupal_map_assoc(array(10, 30, 50, 70, 90, 150, 200, 250, 300));
+  return map_assoc(array(10, 30, 50, 70, 90, 150, 200, 250, 300));
 }
 
 /**
@@ -2404,7 +2405,7 @@ function comment_unpublish_by_keyword_action_form($context) {
     '#title' => t('Keywords'),
     '#type' => 'textarea',
     '#description' => t('The comment will be unpublished if it contains any of the phrases above. Use a case-sensitive, comma-separated list of phrases. Example: funny, bungee jumping, "Company, Inc."'),
-    '#default_value' => isset($context['keywords']) ? drupal_implode_tags($context['keywords']) : '',
+    '#default_value' => isset($context['keywords']) ? implode_tags($context['keywords']) : '',
   );
 
   return $form;
@@ -2416,7 +2417,7 @@ function comment_unpublish_by_keyword_action_form($context) {
  * @see comment_unpublish_by_keyword_action()
  */
 function comment_unpublish_by_keyword_action_submit($form, $form_state) {
-  return array('keywords' => drupal_explode_tags($form_state['values']['keywords']));
+  return array('keywords' => explode_tags($form_state['values']['keywords']));
 }
 
 /**
diff --git a/core/modules/comment/comment.pages.inc b/core/modules/comment/comment.pages.inc
index 5e3d9de..4c166cc 100644
--- a/core/modules/comment/comment.pages.inc
+++ b/core/modules/comment/comment.pages.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -28,7 +29,7 @@
  */
 function comment_reply($node, $pid = NULL) {
   // Set the breadcrumb trail.
-  drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->title, 'node/' . $node->nid)));
+  set_breadcrumb(array(l(t('Home'), NULL), l($node->title, 'node/' . $node->nid)));
   $op = isset($_POST['op']) ? $_POST['op'] : '';
   $build = array();
 
@@ -36,11 +37,11 @@ function comment_reply($node, $pid = NULL) {
   if ($op == t('Preview')) {
     if (user_access('post comments')) {
       $comment = entity_create('comment', array('nid' => $node->nid, 'pid' => $pid));
-      $build['comment_form'] = drupal_get_form("comment_node_{$node->type}_form", $comment);
+      $build['comment_form'] = get_form("comment_node_{$node->type}_form", $comment);
     }
     else {
-      drupal_set_message(t('You are not authorized to post comments.'), 'error');
-      drupal_goto("node/$node->nid");
+      set_message(t('You are not authorized to post comments.'), 'error');
+      redirect("node/$node->nid");
     }
   }
   else {
@@ -57,8 +58,8 @@ function comment_reply($node, $pid = NULL) {
           // parent comment both belong to the same parent node.
           if ($comment->nid != $node->nid) {
             // Attempting to reply to a comment not belonging to the current nid.
-            drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
-            drupal_goto("node/$node->nid");
+            set_message(t('The comment you are replying to does not exist.'), 'error');
+            redirect("node/$node->nid");
           }
           // Display the parent comment
           $comment->node_type = 'comment_node_' . $node->type;
@@ -67,13 +68,13 @@ function comment_reply($node, $pid = NULL) {
           $build['comment_parent'] = comment_view($comment, $node);
         }
         else {
-          drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
-          drupal_goto("node/$node->nid");
+          set_message(t('The comment you are replying to does not exist.'), 'error');
+          redirect("node/$node->nid");
         }
       }
       else {
-        drupal_set_message(t('You are not authorized to view comments.'), 'error');
-        drupal_goto("node/$node->nid");
+        set_message(t('You are not authorized to view comments.'), 'error');
+        redirect("node/$node->nid");
       }
     }
     // This is the case where the comment is in response to a node. Display the node.
@@ -83,16 +84,16 @@ function comment_reply($node, $pid = NULL) {
 
     // Should we show the reply box?
     if ($node->comment != COMMENT_NODE_OPEN) {
-      drupal_set_message(t("This discussion is closed: you can't post new comments."), 'error');
-      drupal_goto("node/$node->nid");
+      set_message(t("This discussion is closed: you can't post new comments."), 'error');
+      redirect("node/$node->nid");
     }
     elseif (user_access('post comments')) {
       $comment = entity_create('comment', array('nid' => $node->nid, 'pid' => $pid));
-      $build['comment_form'] = drupal_get_form("comment_node_{$node->type}_form", $comment);
+      $build['comment_form'] = get_form("comment_node_{$node->type}_form", $comment);
     }
     else {
-      drupal_set_message(t('You are not authorized to post comments.'), 'error');
-      drupal_goto("node/$node->nid");
+      set_message(t('You are not authorized to post comments.'), 'error');
+      redirect("node/$node->nid");
     }
   }
 
@@ -110,15 +111,15 @@ function comment_reply($node, $pid = NULL) {
  * @see comment_menu()
  */
 function comment_approve($cid) {
-  if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], "comment/$cid/approve")) {
+  if (!isset($_GET['token']) || !valid_token($_GET['token'], "comment/$cid/approve")) {
     return MENU_ACCESS_DENIED;
   }
   if ($comment = comment_load($cid)) {
     $comment->status = COMMENT_PUBLISHED;
     comment_save($comment);
 
-    drupal_set_message(t('Comment approved.'));
-    drupal_goto('node/' . $comment->nid);
+    set_message(t('Comment approved.'));
+    redirect('node/' . $comment->nid);
   }
   return MENU_NOT_FOUND;
 }
diff --git a/core/modules/comment/comment.test b/core/modules/comment/comment.test
index 9a77853..cbf2a5b 100644
--- a/core/modules/comment/comment.test
+++ b/core/modules/comment/comment.test
@@ -1,11 +1,12 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
  * Tests for the Comment module.
  */
 
-class CommentHelperCase extends DrupalWebTestCase {
+class CommentHelperCase extends WebTestCase {
   protected $admin_user;
   protected $web_user;
   protected $node;
@@ -36,7 +37,7 @@ class CommentHelperCase extends DrupalWebTestCase {
     $edit = array();
     $edit['comment_body[' . $langcode . '][0][value]'] = $comment;
 
-    $preview_mode = variable_get('comment_preview_article', DRUPAL_OPTIONAL);
+    $preview_mode = variable_get('comment_preview_article', OPTIONAL);
     $subject_mode = variable_get('comment_subject_field_article', 1);
 
     // Must get the page before we test for fields.
@@ -55,19 +56,19 @@ class CommentHelperCase extends DrupalWebTestCase {
       $edit += $contact;
     }
     switch ($preview_mode) {
-      case DRUPAL_REQUIRED:
+      case REQUIRED:
         // Preview required so no save button should be found.
         $this->assertNoFieldByName('op', t('Save'), t('Save button not found.'));
         $this->drupalPost(NULL, $edit, t('Preview'));
         // Don't break here so that we can test post-preview field presence and
         // function below.
-      case DRUPAL_OPTIONAL:
+      case OPTIONAL:
         $this->assertFieldByName('op', t('Preview'), t('Preview button found.'));
         $this->assertFieldByName('op', t('Save'), t('Save button found.'));
         $this->drupalPost(NULL, $edit, t('Save'));
         break;
 
-      case DRUPAL_DISABLED:
+      case DISABLED:
         $this->assertNoFieldByName('op', t('Preview'), t('Preview button not found.'));
         $this->assertFieldByName('op', t('Save'), t('Save button found.'));
         $this->drupalPost(NULL, $edit, t('Save'));
@@ -143,19 +144,19 @@ class CommentHelperCase extends DrupalWebTestCase {
    * Sets the value governing the previewing mode for the comment form.
    *
    * @param int $mode
-   *   The preview mode: DRUPAL_DISABLED, DRUPAL_OPTIONAL or DRUPAL_REQUIRED.
+   *   The preview mode: DISABLED, OPTIONAL or REQUIRED.
    */
   function setCommentPreview($mode) {
     switch ($mode) {
-      case DRUPAL_DISABLED:
+      case DISABLED:
         $mode_text = 'disabled';
         break;
 
-      case DRUPAL_OPTIONAL:
+      case OPTIONAL:
         $mode_text = 'optional';
         break;
 
-      case DRUPAL_REQUIRED:
+      case REQUIRED:
         $mode_text = 'required';
         break;
     }
@@ -279,7 +280,7 @@ class CommentInterfaceTest extends CommentHelperCase {
     $langcode = LANGUAGE_NONE;
     // Set comments to have subject and preview disabled.
     $this->drupalLogin($this->admin_user);
-    $this->setCommentPreview(DRUPAL_DISABLED);
+    $this->setCommentPreview(DISABLED);
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(FALSE);
     $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
@@ -298,7 +299,7 @@ class CommentInterfaceTest extends CommentHelperCase {
     $this->drupalLogout();
     $this->drupalLogin($this->admin_user);
     $this->setCommentSubject(TRUE);
-    $this->setCommentPreview(DRUPAL_REQUIRED);
+    $this->setCommentPreview(REQUIRED);
     $this->drupalLogout();
 
     // Create comment #2 that allows subject and requires preview.
@@ -318,7 +319,7 @@ class CommentInterfaceTest extends CommentHelperCase {
     $this->drupalLogout();
     $this->drupalLogin($this->admin_user);
     $this->setCommentSubject(TRUE);
-    $this->setCommentPreview(DRUPAL_OPTIONAL);
+    $this->setCommentPreview(OPTIONAL);
 
     // Test changing the comment author to "Anonymous".
     $this->drupalGet('comment/' . $comment->id . '/edit');
@@ -489,7 +490,7 @@ class CommentInterfaceTest extends CommentHelperCase {
     $langcode = LANGUAGE_NONE;
     // Set comments to have subject and preview disabled.
     $this->drupalLogin($this->admin_user);
-    $this->setCommentPreview(DRUPAL_DISABLED);
+    $this->setCommentPreview(DISABLED);
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(FALSE);
     $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
@@ -521,7 +522,7 @@ class CommentInterfaceTest extends CommentHelperCase {
     // Prepare for anonymous comment submission (comment approval enabled).
     variable_set('user_register', USER_REGISTER_VISITORS);
     $this->drupalLogin($this->admin_user);
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(ANONYMOUS_RID, array(
       'access comments' => TRUE,
       'post comments' => TRUE,
       'skip comment approval' => FALSE,
@@ -545,7 +546,7 @@ class CommentInterfaceTest extends CommentHelperCase {
 
     // Prepare for anonymous comment submission (no approval required).
     $this->drupalLogin($this->admin_user);
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(ANONYMOUS_RID, array(
       'access comments' => TRUE,
       'post comments' => TRUE,
       'skip comment approval' => TRUE,
@@ -709,12 +710,12 @@ class CommentInterfaceTest extends CommentHelperCase {
     variable_set('user_register', $info['user_register']);
 
     // Change user permissions.
-    $rid = ($this->loggedInUser ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID);
+    $rid = ($this->loggedInUser ? AUTHENTICATED_RID : ANONYMOUS_RID);
     $perms = array_intersect_key($info, array('access comments' => 1, 'post comments' => 1, 'skip comment approval' => 1, 'edit own comments' => 1));
     user_role_change_permissions($rid, $perms);
 
     // Output verbose debugging information.
-    // @see DrupalTestCase::error()
+    // @see TestCase::error()
     $t_form = array(
       COMMENT_FORM_BELOW => 'below',
       COMMENT_FORM_SEPARATE_PAGE => 'separate page',
@@ -860,7 +861,7 @@ class CommentPreviewTest extends CommentHelperCase {
 
     // As admin user, configure comment settings.
     $this->drupalLogin($this->admin_user);
-    $this->setCommentPreview(DRUPAL_OPTIONAL);
+    $this->setCommentPreview(OPTIONAL);
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(TRUE);
     $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
@@ -890,7 +891,7 @@ class CommentPreviewTest extends CommentHelperCase {
     $langcode = LANGUAGE_NONE;
     $web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval'));
     $this->drupalLogin($this->admin_user);
-    $this->setCommentPreview(DRUPAL_OPTIONAL);
+    $this->setCommentPreview(OPTIONAL);
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(TRUE);
     $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
@@ -971,7 +972,7 @@ class CommentAnonymous extends CommentHelperCase {
   function testAnonymous() {
     $this->drupalLogin($this->admin_user);
     // Enabled anonymous user comments.
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(ANONYMOUS_RID, array(
       'access comments' => TRUE,
       'post comments' => TRUE,
       'skip comment approval' => TRUE,
@@ -1058,7 +1059,7 @@ class CommentAnonymous extends CommentHelperCase {
     $this->drupalLogout();
 
     // Reset.
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(ANONYMOUS_RID, array(
       'access comments' => FALSE,
       'post comments' => FALSE,
       'skip comment approval' => FALSE,
@@ -1077,7 +1078,7 @@ class CommentAnonymous extends CommentHelperCase {
     $this->assertNoFieldByName('subject', '', t('Subject field not found.'));
     $this->assertNoFieldByName("comment_body[$langcode][0][value]", '', t('Comment field not found.'));
 
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(ANONYMOUS_RID, array(
       'access comments' => TRUE,
       'post comments' => FALSE,
       'skip comment approval' => FALSE,
@@ -1087,7 +1088,7 @@ class CommentAnonymous extends CommentHelperCase {
     $this->assertLink('Log in', 1, t('Link to log in was found.'));
     $this->assertLink('register', 1, t('Link to register was found.'));
 
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(ANONYMOUS_RID, array(
       'access comments' => FALSE,
       'post comments' => TRUE,
       'skip comment approval' => TRUE,
@@ -1125,7 +1126,7 @@ class CommentPagerTest extends CommentHelperCase {
     // Set comment variables.
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(TRUE);
-    $this->setCommentPreview(DRUPAL_DISABLED);
+    $this->setCommentPreview(DISABLED);
 
     // Create a node and three comments.
     $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
@@ -1198,7 +1199,7 @@ class CommentPagerTest extends CommentHelperCase {
     // Set comment variables.
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(TRUE);
-    $this->setCommentPreview(DRUPAL_DISABLED);
+    $this->setCommentPreview(DISABLED);
 
     // Display all the comments on the same page.
     $this->setCommentsPerPage(1000);
@@ -1298,7 +1299,7 @@ class CommentPagerTest extends CommentHelperCase {
     // Set comment variables.
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(TRUE);
-    $this->setCommentPreview(DRUPAL_DISABLED);
+    $this->setCommentPreview(DISABLED);
 
     // Set comments to one per page so that we are able to test paging without
     // needing to insert large numbers of comments.
@@ -1386,7 +1387,7 @@ class CommentNodeAccessTest extends CommentHelperCase {
   }
 
   function setUp() {
-    DrupalWebTestCase::setUp('comment', 'search', 'node_access_test');
+    WebTestCase::setUp('comment', 'search', 'node_access_test');
     node_access_rebuild();
 
     // Create users and test node.
@@ -1402,7 +1403,7 @@ class CommentNodeAccessTest extends CommentHelperCase {
     $langcode = LANGUAGE_NONE;
     // Set comments to have subject required and preview disabled.
     $this->drupalLogin($this->admin_user);
-    $this->setCommentPreview(DRUPAL_DISABLED);
+    $this->setCommentPreview(DISABLED);
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(TRUE);
     $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
@@ -1454,7 +1455,7 @@ class CommentApprovalTest extends CommentHelperCase {
    */
   function testApprovalAdminInterface() {
     // Set anonymous comments to require approval.
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(ANONYMOUS_RID, array(
       'access comments' => TRUE,
       'post comments' => TRUE,
       'skip comment approval' => FALSE,
@@ -1523,7 +1524,7 @@ class CommentApprovalTest extends CommentHelperCase {
    */
   function testApprovalNodeInterface() {
     // Set anonymous comments to require approval.
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(ANONYMOUS_RID, array(
       'access comments' => TRUE,
       'post comments' => TRUE,
       'skip comment approval' => FALSE,
@@ -1602,13 +1603,13 @@ class CommentBlockFunctionalTest extends CommentHelperCase {
     // Test that a user without the 'access comments' permission cannot see the
     // block.
     $this->drupalLogout();
-    user_role_revoke_permissions(DRUPAL_ANONYMOUS_RID, array('access comments'));
+    user_role_revoke_permissions(ANONYMOUS_RID, array('access comments'));
     // drupalCreateNode() does not automatically flush content caches unlike
     // posting a node from a node form.
     cache_clear_all();
     $this->drupalGet('');
     $this->assertNoText($block['title'], t('Block was not found.'));
-    user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access comments'));
+    user_role_grant_permissions(ANONYMOUS_RID, array('access comments'));
 
     // Test that a user with the 'access comments' permission can see the
     // block.
@@ -1707,7 +1708,7 @@ class CommentContentRebuild extends CommentHelperCase {
     // Update the comment settings so preview isn't required.
     $this->drupalLogin($this->admin_user);
     $this->setCommentSubject(TRUE);
-    $this->setCommentPreview(DRUPAL_OPTIONAL);
+    $this->setCommentPreview(OPTIONAL);
     $this->drupalLogout();
 
     // Log in as the web user and add the comment.
diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc
index 20de487..5c5475e 100644
--- a/core/modules/comment/comment.tokens.inc
+++ b/core/modules/comment/comment.tokens.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/comment/comment.tpl.php b/core/modules/comment/comment.tpl.php
index 678f798..966aecb 100644
--- a/core/modules/comment/comment.tpl.php
+++ b/core/modules/comment/comment.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/contact/contact.admin.inc b/core/modules/contact/contact.admin.inc
index 4a8ee39..0c00aad 100644
--- a/core/modules/contact/contact.admin.inc
+++ b/core/modules/contact/contact.admin.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -183,13 +184,13 @@ function contact_category_edit_form_submit($form, &$form_state) {
   }
 
   if (empty($form_state['values']['cid'])) {
-    drupal_write_record('contact', $form_state['values']);
+    write_record('contact', $form_state['values']);
   }
   else {
-    drupal_write_record('contact', $form_state['values'], array('cid'));
+    write_record('contact', $form_state['values'], array('cid'));
   }
 
-  drupal_set_message(t('Category %category has been saved.', array('%category' => $form_state['values']['category'])));
+  set_message(t('Category %category has been saved.', array('%category' => $form_state['values']['category'])));
   watchdog('contact', 'Category %category has been saved.', array('%category' => $form_state['values']['category']), WATCHDOG_NOTICE, l(t('Edit'), 'admin/structure/contact/edit/' . $form_state['values']['cid']));
   $form_state['redirect'] = 'admin/structure/contact';
 }
@@ -232,7 +233,7 @@ function contact_category_delete_form_submit($form, &$form_state) {
     ->condition('cid', $contact['cid'])
     ->execute();
 
-  drupal_set_message(t('Category %category has been deleted.', array('%category' => $contact['category'])));
+  set_message(t('Category %category has been deleted.', array('%category' => $contact['category'])));
   watchdog('contact', 'Category %category has been deleted.', array('%category' => $contact['category']), WATCHDOG_NOTICE);
 
   $form_state['redirect'] = 'admin/structure/contact';
diff --git a/core/modules/contact/contact.install b/core/modules/contact/contact.install
index 7ddea45..9d87fdb 100644
--- a/core/modules/contact/contact.install
+++ b/core/modules/contact/contact.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module
index 2858e49..59e043b 100644
--- a/core/modules/contact/contact.module
+++ b/core/modules/contact/contact.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -64,7 +65,7 @@ function contact_menu() {
   );
   $items['admin/structure/contact/add'] = array(
     'title' => 'Add category',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('contact_category_edit_form'),
     'access arguments' => array('administer contact forms'),
     'type' => MENU_LOCAL_ACTION,
@@ -73,21 +74,21 @@ function contact_menu() {
   );
   $items['admin/structure/contact/edit/%contact'] = array(
     'title' => 'Edit contact category',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('contact_category_edit_form', 4),
     'access arguments' => array('administer contact forms'),
     'file' => 'contact.admin.inc',
   );
   $items['admin/structure/contact/delete/%contact'] = array(
     'title' => 'Delete contact',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('contact_category_delete_form', 4),
     'access arguments' => array('administer contact forms'),
     'file' => 'contact.admin.inc',
   );
   $items['contact'] = array(
     'title' => 'Contact',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('contact_site_form'),
     'access arguments' => array('access site-wide contact form'),
     'type' => MENU_SUGGESTED_ITEM,
@@ -95,7 +96,7 @@ function contact_menu() {
   );
   $items['user/%user/contact'] = array(
     'title' => 'Contact',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('contact_personal_form', 1),
     'type' => MENU_LOCAL_TASK,
     'access callback' => '_contact_personal_tab_access',
diff --git a/core/modules/contact/contact.pages.inc b/core/modules/contact/contact.pages.inc
index a2927be..2d572e6 100644
--- a/core/modules/contact/contact.pages.inc
+++ b/core/modules/contact/contact.pages.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -22,8 +23,8 @@ function contact_site_form($form, &$form_state) {
   $limit = variable_get('contact_threshold_limit', 5);
   $window = variable_get('contact_threshold_window', 3600);
   if (!flood_is_allowed('contact', $limit, $window) && !user_access('administer contact forms')) {
-    drupal_set_message(t("You cannot send more than %limit messages in @interval. Try again later.", array('%limit' => $limit, '@interval' => format_interval($window))), 'error');
-    drupal_access_denied();
+    set_message(t("You cannot send more than %limit messages in @interval. Try again later.", array('%limit' => $limit, '@interval' => format_interval($window))), 'error');
+    access_denied();
     drupal_exit();
   }
 
@@ -40,10 +41,10 @@ function contact_site_form($form, &$form_state) {
   // If there are no categories, do not display the form.
   if (!$categories) {
     if (user_access('administer contact forms')) {
-      drupal_set_message(t('The contact form has not been configured. <a href="@add">Add one or more categories</a> to the form.', array('@add' => url('admin/structure/contact/add'))), 'error');
+      set_message(t('The contact form has not been configured. <a href="@add">Add one or more categories</a> to the form.', array('@add' => url('admin/structure/contact/add'))), 'error');
     }
     else {
-      drupal_not_found();
+      not_found();
       drupal_exit();
     }
   }
@@ -152,16 +153,16 @@ function contact_site_form_submit($form, &$form_state) {
   $from = $values['sender']->mail;
 
   // Send the e-mail to the recipients using the site default language.
-  drupal_mail('contact', 'page_mail', $to, language_default(), $values, $from);
+  mail('contact', 'page_mail', $to, language_default(), $values, $from);
 
   // If the user requests it, send a copy using the current language.
   if ($values['copy']) {
-    drupal_mail('contact', 'page_copy', $from, $language, $values, $from);
+    mail('contact', 'page_copy', $from, $language, $values, $from);
   }
 
   // Send an auto-reply if necessary using the current language.
   if ($values['category']['reply']) {
-    drupal_mail('contact', 'page_autoreply', $from, $language, $values, $to);
+    mail('contact', 'page_autoreply', $from, $language, $values, $to);
   }
 
   flood_register_event('contact', variable_get('contact_threshold_window', 3600));
@@ -169,7 +170,7 @@ function contact_site_form_submit($form, &$form_state) {
 
   // Jump to home page rather than back to contact page to avoid
   // contradictory messages if flood control has been activated.
-  drupal_set_message(t('Your message has been sent.'));
+  set_message(t('Your message has been sent.'));
   $form_state['redirect'] = '';
 }
 
@@ -190,12 +191,12 @@ function contact_personal_form($form, &$form_state, $recipient) {
   $limit = variable_get('contact_threshold_limit', 5);
   $window = variable_get('contact_threshold_window', 3600);
   if (!flood_is_allowed('contact', $limit, $window) && !user_access('administer contact forms') && !user_access('administer users')) {
-    drupal_set_message(t("You cannot send more than %limit messages in @interval. Try again later.", array('%limit' => $limit, '@interval' => format_interval($window))), 'error');
-    drupal_access_denied();
+    set_message(t("You cannot send more than %limit messages in @interval. Try again later.", array('%limit' => $limit, '@interval' => format_interval($window))), 'error');
+    access_denied();
     drupal_exit();
   }
 
-  drupal_set_title(t('Contact @username', array('@username' => user_format_name($recipient))), PASS_THROUGH);
+  set_title(t('Contact @username', array('@username' => user_format_name($recipient))), PASS_THROUGH);
 
   if (!$user->uid) {
     $form['#attached']['library'][] = array('system', 'jquery.cookie');
@@ -287,17 +288,17 @@ function contact_personal_form_submit($form, &$form_state) {
   $from = $values['sender']->mail;
 
   // Send the e-mail in the requested user language.
-  drupal_mail('contact', 'user_mail', $to, user_preferred_language($values['recipient']), $values, $from);
+  mail('contact', 'user_mail', $to, user_preferred_language($values['recipient']), $values, $from);
 
   // Send a copy if requested, using current page language.
   if ($values['copy']) {
-    drupal_mail('contact', 'user_copy', $from, $language, $values, $from);
+    mail('contact', 'user_copy', $from, $language, $values, $from);
   }
 
   flood_register_event('contact', variable_get('contact_threshold_window', 3600));
   watchdog('mail', '%sender-name (@sender-from) sent %recipient-name an e-mail.', array('%sender-name' => $values['name'], '@sender-from' => $from, '%recipient-name' => $values['recipient']->name));
 
   // Jump to the contacted user's profile page.
-  drupal_set_message(t('Your message has been sent.'));
+  set_message(t('Your message has been sent.'));
   $form_state['redirect'] = user_access('access user profiles') ? 'user/' . $values['recipient']->uid : '';
 }
diff --git a/core/modules/contact/contact.test b/core/modules/contact/contact.test
index 48c8bb0..1221c0e 100644
--- a/core/modules/contact/contact.test
+++ b/core/modules/contact/contact.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 /**
  * @file
  * Tests for the Contact module.
@@ -7,7 +8,7 @@
 /**
  * Tests the site-wide contact form.
  */
-class ContactSitewideTestCase extends DrupalWebTestCase {
+class ContactSitewideTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Site-wide contact form',
@@ -42,7 +43,7 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
     $this->deleteCategories();
 
     // Ensure that the contact form won't be shown without categories.
-    user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form'));
+    user_role_grant_permissions(ANONYMOUS_RID, array('access site-wide contact form'));
     $this->drupalLogout();
     $this->drupalGet('contact');
     $this->assertResponse(404);
@@ -83,7 +84,7 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
     $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), t('Category successfully saved.'));
 
     // Ensure that the contact form is shown without a category selection input.
-    user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form'));
+    user_role_grant_permissions(ANONYMOUS_RID, array('access site-wide contact form'));
     $this->drupalLogout();
     $this->drupalGet('contact');
     $this->assertText(t('Your e-mail address'), t('Contact form is shown when there is one category.'));
@@ -109,12 +110,12 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
     $this->drupalLogout();
 
     // Check to see that anonymous user cannot see contact page without permission.
-    user_role_revoke_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form'));
+    user_role_revoke_permissions(ANONYMOUS_RID, array('access site-wide contact form'));
     $this->drupalGet('contact');
     $this->assertResponse(403, t('Access denied to anonymous user without permission.'));
 
     // Give anonymous user permission and see that page is viewable.
-    user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form'));
+    user_role_grant_permissions(ANONYMOUS_RID, array('access site-wide contact form'));
     $this->drupalGet('contact');
     $this->assertResponse(200, t('Access granted to anonymous user with permission.'));
 
@@ -183,7 +184,7 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
     // We are testing the auto-reply, so there should be one e-mail going to the sender.
     $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email, 'from' => 'foo@example.com'));
     $this->assertEqual(count($captured_emails), 1, t('Auto-reply e-mail was sent to the sender for category "foo".'), t('Contact'));
-    $this->assertEqual($captured_emails[0]['body'], drupal_html_to_text($foo_autoreply), t('Auto-reply e-mail body is correct for category "foo".'), t('Contact'));
+    $this->assertEqual($captured_emails[0]['body'], html_to_text($foo_autoreply), t('Auto-reply e-mail body is correct for category "foo".'), t('Contact'));
 
     // Test the auto-reply for category 'bar'.
     $email = $this->randomName(32) . '@example.com';
@@ -192,7 +193,7 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
     // Auto-reply for category 'bar' should result in one auto-reply e-mail to the sender.
     $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email, 'from' => 'bar@example.com'));
     $this->assertEqual(count($captured_emails), 1, t('Auto-reply e-mail was sent to the sender for category "bar".'), t('Contact'));
-    $this->assertEqual($captured_emails[0]['body'], drupal_html_to_text($bar_autoreply), t('Auto-reply e-mail body is correct for category "bar".'), t('Contact'));
+    $this->assertEqual($captured_emails[0]['body'], html_to_text($bar_autoreply), t('Auto-reply e-mail body is correct for category "bar".'), t('Contact'));
 
     // Verify that no auto-reply is sent when the auto-reply field is left blank.
     $email = $this->randomName(32) . '@example.com';
@@ -298,7 +299,7 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
 /**
  * Tests the personal contact form.
  */
-class ContactPersonalTestCase extends DrupalWebTestCase {
+class ContactPersonalTestCase extends WebTestCase {
   private $admin_user;
   private $web_user;
   private $contact_user;
@@ -342,12 +343,12 @@ class ContactPersonalTestCase extends DrupalWebTestCase {
 
     // Test that anonymous users can access the contact form.
     $this->drupalLogout();
-    user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access user contact forms'));
+    user_role_grant_permissions(ANONYMOUS_RID, array('access user contact forms'));
     $this->drupalGet('user/' . $this->contact_user->uid . '/contact');
     $this->assertResponse(200);
 
     // Revoke the personal contact permission for the anonymous user.
-    user_role_revoke_permissions(DRUPAL_ANONYMOUS_RID, array('access user contact forms'));
+    user_role_revoke_permissions(ANONYMOUS_RID, array('access user contact forms'));
     $this->drupalGet('user/' . $this->contact_user->uid . '/contact');
     $this->assertResponse(403);
 
diff --git a/core/modules/contextual/contextual.api.php b/core/modules/contextual/contextual.api.php
index e8f33ee..36957a5 100644
--- a/core/modules/contextual/contextual.api.php
+++ b/core/modules/contextual/contextual.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/contextual/contextual.module b/core/modules/contextual/contextual.module
index 7b14a3f..bd93780 100644
--- a/core/modules/contextual/contextual.module
+++ b/core/modules/contextual/contextual.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -39,7 +40,7 @@ function contextual_permission() {
  * Implements hook_library_info().
  */
 function contextual_library_info() {
-  $path = drupal_get_path('module', 'contextual');
+  $path = get_path('module', 'contextual');
   $libraries['contextual-links'] = array(
     'title' => 'Contextual links',
     'website' => 'http://drupal.org/node/473268',
@@ -144,20 +145,20 @@ function contextual_pre_render_links($element) {
   // Transform contextual links into parameters suitable for theme_link().
   $links = array();
   foreach ($items as $class => $item) {
-    $class = drupal_html_class($class);
+    $class = html_class($class);
     $links[$class] = array(
       'title' => $item['title'],
       'href' => $item['href'],
     );
     // @todo theme_links() should *really* use the same parameters as l().
     $item['localized_options'] += array('query' => array());
-    $item['localized_options']['query'] += drupal_get_destination();
+    $item['localized_options']['query'] += get_destination();
     $links[$class] += $item['localized_options'];
   }
   $element['#links'] = $links;
 
   // Allow modules to alter the renderable contextual links element.
-  drupal_alter('contextual_links_view', $element, $items);
+  alter('contextual_links_view', $element, $items);
 
   // If there are no links, tell drupal_render() to abort rendering.
   if (empty($element['#links'])) {
diff --git a/core/modules/dashboard/dashboard.api.php b/core/modules/dashboard/dashboard.api.php
index 623dd30..cf063e8 100644
--- a/core/modules/dashboard/dashboard.api.php
+++ b/core/modules/dashboard/dashboard.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/dashboard/dashboard.install b/core/modules/dashboard/dashboard.install
index 5021826..0b3d7bb 100644
--- a/core/modules/dashboard/dashboard.install
+++ b/core/modules/dashboard/dashboard.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -52,7 +53,7 @@ function dashboard_enable() {
     return;
   }
   if (!$admin_theme = variable_get('admin_theme')) {
-    drupal_theme_initialize();
+    theme_initialize();
     $admin_theme = $theme_key;
   }
   foreach ($stashed_blocks as $block) {
diff --git a/core/modules/dashboard/dashboard.module b/core/modules/dashboard/dashboard.module
index 1891db5..4d2c75b 100644
--- a/core/modules/dashboard/dashboard.module
+++ b/core/modules/dashboard/dashboard.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -247,7 +249,7 @@ function dashboard_theme() {
       // When building the form for configuring dashboard blocks, reuse the
       // Block module's template for the main block configuration form.
       'template' => 'block-admin-display-form',
-      'path' => drupal_get_path('module', 'block'),
+      'path' => get_path('module', 'block'),
       'file' => 'block.admin.inc',
       'render element' => 'form',
     ),
@@ -281,7 +283,7 @@ function dashboard_admin($launch_customize = FALSE) {
       'drawer' => url('admin/dashboard/drawer'),
       'blockContent' => url('admin/dashboard/block-content'),
       'updatePath' => url('admin/dashboard/update'),
-      'formToken' => drupal_get_token('dashboard-update'),
+      'formToken' => get_token('dashboard-update'),
       'launchCustomize' => $launch_customize,
       'dashboard' => url('admin/dashboard'),
       'emptyBlockText' => t('(empty)'),
@@ -295,7 +297,7 @@ function dashboard_admin($launch_customize = FALSE) {
     '#access' => user_access('administer blocks'),
     '#attached' => array(
       'js' => array(
-        drupal_get_path('module', 'dashboard') . '/dashboard.js',
+        get_path('module', 'dashboard') . '/dashboard.js',
         array('data' => $js_settings, 'type' => 'setting'),
       ),
       'library' => array(array('system', 'ui.sortable')),
@@ -318,7 +320,7 @@ function dashboard_admin($launch_customize = FALSE) {
  */
 function dashboard_admin_blocks() {
   global $theme_key;
-  drupal_theme_initialize();
+  theme_initialize();
   module_load_include('inc', 'block', 'block.admin');
 
   // Prepare the blocks for the current theme, and remove those that are
@@ -336,7 +338,7 @@ function dashboard_admin_blocks() {
 
   // Pass in the above blocks and dashboard regions to the form, so that only
   // dashboard-related regions will be displayed.
-  return drupal_get_form('dashboard_admin_display_form', $blocks, $theme_key, $dashboard_regions);
+  return get_form('dashboard_admin_display_form', $blocks, $theme_key, $dashboard_regions);
 }
 
 /**
@@ -395,7 +397,7 @@ function dashboard_form_dashboard_admin_display_form_alter(&$form, &$form_state)
  */
 function dashboard_form_block_admin_configure_alter(&$form, &$form_state) {
   global $theme_key;
-  drupal_theme_initialize();
+  theme_initialize();
   // Hide the dashboard regions from the region select list on the block
   // configuration form, for all themes except the current theme (since the
   // other themes do not display the dashboard).
@@ -466,7 +468,7 @@ function dashboard_is_visible() {
  */
 function dashboard_region_descriptions() {
   $regions = module_invoke_all('dashboard_regions');
-  drupal_alter('dashboard_regions', $regions);
+  alter('dashboard_regions', $regions);
   return $regions;
 }
 
@@ -526,7 +528,7 @@ function dashboard_show_disabled() {
  * @see dashboard_menu()
  */
 function dashboard_show_block_content($module, $delta) {
-  drupal_theme_initialize();
+  theme_initialize();
   global $theme_key;
 
   $blocks = array();
@@ -548,10 +550,10 @@ function dashboard_show_block_content($module, $delta) {
  * Sets the new weight of each region according to the drag-and-drop order.
  */
 function dashboard_update() {
-  drupal_theme_initialize();
+  theme_initialize();
   global $theme_key;
   // Check the form token to make sure we have a valid request.
-  if (!empty($_REQUEST['form_token']) && drupal_valid_token($_REQUEST['form_token'], 'dashboard-update')) {
+  if (!empty($_REQUEST['form_token']) && valid_token($_REQUEST['form_token'], 'dashboard-update')) {
     parse_str($_REQUEST['regions'], $regions);
     foreach ($regions as $region_name => $blocks) {
       if ($region_name == 'disabled_blocks') {
@@ -583,7 +585,7 @@ function dashboard_update() {
           ->execute();
       }
     }
-    drupal_set_message(t('The configuration options have been saved.'), 'status', FALSE);
+    set_message(t('The configuration options have been saved.'), 'status', FALSE);
   }
   drupal_exit();
 }
@@ -600,7 +602,7 @@ function dashboard_update() {
  */
 function theme_dashboard($variables) {
   extract($variables);
-  drupal_add_css(drupal_get_path('module', 'dashboard') . '/dashboard.css');
+  add_css(get_path('module', 'dashboard') . '/dashboard.css');
   return '<div id="dashboard" class="clearfix">' . $element['#children'] . '</div>';
 }
 
diff --git a/core/modules/dashboard/dashboard.test b/core/modules/dashboard/dashboard.test
index 56bdb13..e126580 100644
--- a/core/modules/dashboard/dashboard.test
+++ b/core/modules/dashboard/dashboard.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -8,7 +9,7 @@
 /**
  * Tests the Dashboard module blocks.
  */
-class DashboardBlocksTestCase extends DrupalWebTestCase {
+class DashboardBlocksTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Dashboard blocks',
diff --git a/core/modules/dblog/dblog.admin.inc b/core/modules/dblog/dblog.admin.inc
index b2da7ed..1024377 100644
--- a/core/modules/dblog/dblog.admin.inc
+++ b/core/modules/dblog/dblog.admin.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -25,8 +26,8 @@ function dblog_overview() {
     WATCHDOG_EMERGENCY     => 'dblog-emerg',
   );
 
-  $build['dblog_filter_form'] = drupal_get_form('dblog_filter_form');
-  $build['dblog_clear_log_form'] = drupal_get_form('dblog_clear_log_form');
+  $build['dblog_filter_form'] = get_form('dblog_filter_form');
+  $build['dblog_clear_log_form'] = get_form('dblog_clear_log_form');
 
   $header = array(
     '', // Icon column.
@@ -62,7 +63,7 @@ function dblog_overview() {
         filter_xss($dblog->link),
       ),
       // Attributes for tr
-      'class' => array(drupal_html_class('dblog-' . $dblog->type), $classes[$dblog->severity]),
+      'class' => array(html_class('dblog-' . $dblog->type), $classes[$dblog->severity]),
     );
   }
 
@@ -377,5 +378,5 @@ function dblog_clear_log_form($form) {
 function dblog_clear_log_submit() {
   $_SESSION['dblog_overview_filter'] = array();
   db_delete('watchdog')->execute();
-  drupal_set_message(t('Database log cleared.'));
+  set_message(t('Database log cleared.'));
 }
diff --git a/core/modules/dblog/dblog.install b/core/modules/dblog/dblog.install
index 23f85ba..5023cf7 100644
--- a/core/modules/dblog/dblog.install
+++ b/core/modules/dblog/dblog.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module
index 496a043..eeabdb7 100644
--- a/core/modules/dblog/dblog.module
+++ b/core/modules/dblog/dblog.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -89,7 +90,7 @@ function dblog_menu() {
 function dblog_init() {
   if (arg(0) == 'admin' && arg(1) == 'reports') {
     // Add the CSS for this module
-    drupal_add_css(drupal_get_path('module', 'dblog') . '/dblog.css');
+    add_css(get_path('module', 'dblog') . '/dblog.css');
   }
 }
 
@@ -165,7 +166,7 @@ function dblog_form_system_logging_settings_alter(&$form, $form_state) {
     '#type' => 'select',
     '#title' => t('Database log messages to keep'),
     '#default_value' => variable_get('dblog_row_limit', 1000),
-    '#options' => array(0 => t('All')) + drupal_map_assoc(array(100, 1000, 10000, 100000, 1000000)),
+    '#options' => array(0 => t('All')) + map_assoc(array(100, 1000, 10000, 100000, 1000000)),
     '#description' => t('The maximum number of messages to keep in the database log. Requires a <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status')))
   );
   $form['actions']['#weight'] = 1;
diff --git a/core/modules/dblog/dblog.test b/core/modules/dblog/dblog.test
index ffd3e8a..e379bd1 100644
--- a/core/modules/dblog/dblog.test
+++ b/core/modules/dblog/dblog.test
@@ -1,11 +1,13 @@
 <?php
+namespace Drupal;
+use SimpleXMLElement;
 
 /**
  * @file
  * Tests for dblog.module.
  */
 
-class DBLogTestCase extends DrupalWebTestCase {
+class DBLogTestCase extends WebTestCase {
   protected $big_user;
   protected $any_user;
 
diff --git a/core/modules/entity/entity.api.php b/core/modules/entity/entity.api.php
index e983778..b336e5e 100644
--- a/core/modules/entity/entity.api.php
+++ b/core/modules/entity/entity.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -22,18 +23,18 @@
  *   properties of those types that the system needs to know about:
  *   - label: The human-readable name of the type.
  *   - controller class: The name of the class that is used to load the objects.
- *     The class has to implement the DrupalEntityControllerInterface interface.
- *     Leave blank to use the DrupalDefaultEntityController implementation.
- *   - base table: (used by DrupalDefaultEntityController) The name of the
+ *     The class has to implement the EntityControllerInterface interface.
+ *     Leave blank to use the DefaultEntityController implementation.
+ *   - base table: (used by DefaultEntityController) The name of the
  *     entity type's base table.
- *   - static cache: (used by DrupalDefaultEntityController) FALSE to disable
+ *   - static cache: (used by DefaultEntityController) FALSE to disable
  *     static caching of entities during a page request. Defaults to TRUE.
  *   - field cache: (used by Field API loading and saving of field data) FALSE
  *     to disable Field API's persistent cache of field data. Only recommended
  *     if a higher level persistent cache is available for the entity type.
  *     Defaults to TRUE.
  *   - load hook: The name of the hook which should be invoked by
- *     DrupalDefaultEntityController:attachLoad(), for example 'node_load'.
+ *     DefaultEntityController:attachLoad(), for example 'node_load'.
  *   - uri callback: A function taking an entity as argument and returning the
  *     uri elements of the entity, e.g. 'path' and 'options'. The actual entity
  *     uri can be constructed by passing these elements to url().
@@ -312,7 +313,7 @@ function hook_entity_predelete($entity, $type) {
     'type' => $type,
     'id' => $id,
   );
-  drupal_write_record('example_deleted_entity_statistics', $ref_count_record);
+  write_record('example_deleted_entity_statistics', $ref_count_record);
 }
 
 /**
diff --git a/core/modules/entity/entity.class.inc b/core/modules/entity/entity.class.inc
index 1dec8ee..d59fbd5 100644
--- a/core/modules/entity/entity.class.inc
+++ b/core/modules/entity/entity.class.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -205,8 +207,8 @@ class Entity implements EntityInterface {
    */
   public function label() {
     $label = FALSE;
-    if (isset($this->entityInfo['label callback']) && function_exists($this->entityInfo['label callback'])) {
-      $label = $this->entityInfo['label callback']($this->entityType, $this);
+    if (isset($this->entityInfo['label callback']) && function_exists($function = 'Drupal\\' . $this->entityInfo['label callback'])) {
+      $label = $function($this->entityType, $this);
     }
     elseif (!empty($this->entityInfo['entity keys']['label']) && isset($this->{$this->entityInfo['entity keys']['label']})) {
       $label = $this->{$this->entityInfo['entity keys']['label']};
@@ -234,13 +236,16 @@ class Entity implements EntityInterface {
     }
 
     // Invoke the callback to get the URI. If there is no callback, return NULL.
-    if (isset($uri_callback) && function_exists($uri_callback)) {
-      $uri = $uri_callback($this);
-      // Pass the entity data to url() so that alter functions do not need to
-      // look up this entity again.
-      $uri['options']['entity_type'] = $this->entityType;
-      $uri['options']['entity'] = $this;
-      return $uri;
+    if (isset($uri_callback)) {
+      $function = 'Drupal\\' . $uri_callback;
+      if (function_exists($function)) {
+        $uri = $function($this);
+        // Pass the entity data to url() so that alter functions do not need to
+        // look up this entity again.
+        $uri['options']['entity_type'] = $this->entityType;
+        $uri['options']['entity'] = $this;
+        return $uri;
+      }
     }
   }
 
@@ -286,7 +291,7 @@ class Entity implements EntityInterface {
     unset($vars['entityInfo'], $vars['idKey'], $vars['bundleKey']);
     // Also key the returned array with the variable names so the method may
     // be easily overridden and customized.
-    return drupal_map_assoc(array_keys($vars));
+    return map_assoc(array_keys($vars));
   }
 
   /**
diff --git a/core/modules/entity/entity.controller.inc b/core/modules/entity/entity.controller.inc
index 04c1f31..7bde268 100644
--- a/core/modules/entity/entity.controller.inc
+++ b/core/modules/entity/entity.controller.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, PDO;
 
 /**
  * @file
@@ -13,13 +15,13 @@
  * this interface.
  *
  * Most simple, SQL-based entity controllers will do better by extending
- * DrupalDefaultEntityController instead of implementing this interface
+ * DefaultEntityController instead of implementing this interface
  * directly.
  */
-interface DrupalEntityControllerInterface {
+interface EntityControllerInterface {
 
   /**
-   * Constructs a new DrupalEntityControllerInterface object.
+   * Constructs a new EntityControllerInterface object.
    *
    * @param $entityType
    *   The entity type for which the instance is created.
@@ -52,12 +54,12 @@ interface DrupalEntityControllerInterface {
 /**
  * Defines a base entity controller class.
  *
- * Default implementation of DrupalEntityControllerInterface.
+ * Default implementation of EntityControllerInterface.
  *
  * This class can be used as-is by most simple entity types. Entity types
  * requiring special handling can extend the class.
  */
-class DrupalDefaultEntityController implements DrupalEntityControllerInterface {
+class DefaultEntityController implements EntityControllerInterface {
 
   /**
    * Static cache of entities.
@@ -85,7 +87,7 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface {
   /**
    * Additional arguments to pass to hook_TYPE_load().
    *
-   * Set before calling DrupalDefaultEntityController::attachLoad().
+   * Set before calling DefaultEntityController::attachLoad().
    *
    * @var array
    */
@@ -124,7 +126,7 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface {
   protected $cache;
 
   /**
-   * Implements DrupalEntityControllerInterface::__construct().
+   * Implements EntityControllerInterface::__construct().
    *
    * Sets basic variables.
    */
@@ -149,7 +151,7 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface {
   }
 
   /**
-   * Implements DrupalEntityControllerInterface::resetCache().
+   * Implements EntityControllerInterface::resetCache().
    */
   public function resetCache(array $ids = NULL) {
     if (isset($ids)) {
@@ -163,7 +165,7 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface {
   }
 
   /**
-   * Implements DrupalEntityControllerInterface::load().
+   * Implements EntityControllerInterface::load().
    */
   public function load($ids = array(), $conditions = array()) {
     $entities = array();
@@ -205,7 +207,7 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface {
         // We provide the necessary arguments for PDO to create objects of the
         // specified entity class.
         // @see EntityInterface::__construct()
-        $query_result->setFetchMode(PDO::FETCH_CLASS, $this->entityInfo['entity class'], array(array(), $this->entityType));
+        $query_result->setFetchMode(PDO::FETCH_CLASS, 'Drupal\\' . $this->entityInfo['entity class'], array(array(), $this->entityType));
       }
       $queried_entities = $query_result->fetchAllAssoc($this->idKey);
     }
@@ -279,7 +281,7 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface {
 
     if ($this->revisionKey) {
       // Add all fields from the {entity_revision} table.
-      $entity_revision_fields = drupal_map_assoc($this->entityInfo['schema_fields_sql']['revision table']);
+      $entity_revision_fields = map_assoc($this->entityInfo['schema_fields_sql']['revision table']);
       // The id field is provided by entity, so remove it.
       unset($entity_revision_fields[$this->idKey]);
 
@@ -337,7 +339,7 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface {
 
     // Call hook_entity_load().
     foreach (module_implements('entity_load') as $module) {
-      $function = $module . '_entity_load';
+      $function = 'Drupal\\' . $module . '_entity_load';
       $function($queried_entities, $this->entityType);
     }
     // Call hook_TYPE_load(). The first argument for hook_TYPE_load() are
@@ -345,7 +347,7 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface {
     // $this->hookLoadArguments.
     $args = array_merge(array($queried_entities), $this->hookLoadArguments);
     foreach (module_implements($this->entityInfo['load hook']) as $module) {
-      call_user_func_array($module . '_' . $this->entityInfo['load hook'], $args);
+      call_user_func_array('Drupal\\' . $module . '_' . $this->entityInfo['load hook'], $args);
     }
   }
 
@@ -401,7 +403,7 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface {
 /**
  * Defines a common interface for entity storage controllers.
  */
-interface EntityStorageControllerInterface extends DrupalEntityControllerInterface {
+interface EntityStorageControllerInterface extends EntityControllerInterface {
 
   /**
    * Deletes permanently saved entities.
@@ -439,7 +441,7 @@ class EntityStorageException extends Exception { }
 /**
  * Implements the entity storage controller interface for the database.
  */
-class EntityDatabaseStorageController extends DrupalDefaultEntityController implements EntityStorageControllerInterface {
+class EntityDatabaseStorageController extends DefaultEntityController implements EntityStorageControllerInterface {
 
   /**
    * Implements EntityStorageControllerInterface::delete().
@@ -494,13 +496,13 @@ class EntityDatabaseStorageController extends DrupalDefaultEntityController impl
       $this->invokeHook('presave', $entity);
 
       if (!$entity->isNew()) {
-        $return = drupal_write_record($this->entityInfo['base table'], $entity, $this->idKey);
+        $return = write_record($this->entityInfo['base table'], $entity, $this->idKey);
         $this->resetCache(array($entity->{$this->idKey}));
         $this->postSave($entity);
         $this->invokeHook('update', $entity);
       }
       else {
-        $return = drupal_write_record($this->entityInfo['base table'], $entity);
+        $return = write_record($this->entityInfo['base table'], $entity);
         $this->postSave($entity);
         $this->invokeHook('insert', $entity);
       }
@@ -557,8 +559,11 @@ class EntityDatabaseStorageController extends DrupalDefaultEntityController impl
    *   The entity object.
    */
   protected function invokeHook($hook, EntityInterface $entity) {
-    if (!empty($this->entityInfo['fieldable']) && function_exists($function = 'field_attach_' . $hook)) {
-      $function($this->entityType, $entity);
+    if (!empty($this->entityInfo['fieldable'])) {
+      $function = 'Drupal\field_attach_' . $hook;
+      if (function_exists($function)) {
+        $function($this->entityType, $entity);
+      }
     }
     // Invoke the hook.
     module_invoke_all($this->entityType . '_' . $hook, $entity);
diff --git a/core/modules/entity/entity.module b/core/modules/entity/entity.module
index 41565b3..af21b87 100644
--- a/core/modules/entity/entity.module
+++ b/core/modules/entity/entity.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -46,11 +48,11 @@ function entity_get_info($entity_type = NULL) {
   global $language;
 
   // Use the advanced drupal_static() pattern, since this is called very often.
-  static $drupal_static_fast;
-  if (!isset($drupal_static_fast)) {
-    $drupal_static_fast['entity_info'] = &drupal_static(__FUNCTION__);
+  static $static_fast;
+  if (!isset($static_fast)) {
+    $static_fast['entity_info'] = &drupal_static(__FUNCTION__);
   }
-  $entity_info = &$drupal_static_fast['entity_info'];
+  $entity_info = &$static_fast['entity_info'];
 
   // hook_entity_info() includes translated strings, so each language is cached
   // separately.
@@ -66,7 +68,7 @@ function entity_get_info($entity_type = NULL) {
       foreach ($entity_info as $name => $data) {
         $entity_info[$name] += array(
           'fieldable' => FALSE,
-          'controller class' => 'DrupalDefaultEntityController',
+          'controller class' => 'DefaultEntityController',
           'static cache' => TRUE,
           'field cache' => TRUE,
           'load hook' => $name . '_load',
@@ -90,16 +92,16 @@ function entity_get_info($entity_type = NULL) {
           $entity_info[$name]['bundles'] = array($name => array('label' => $entity_info[$name]['label']));
         }
         // Prepare entity schema fields SQL info for
-        // DrupalEntityControllerInterface::buildQuery().
+        // EntityControllerInterface::buildQuery().
         if (isset($entity_info[$name]['base table'])) {
-          $entity_info[$name]['schema_fields_sql']['base table'] = drupal_schema_fields_sql($entity_info[$name]['base table']);
+          $entity_info[$name]['schema_fields_sql']['base table'] = schema_fields_sql($entity_info[$name]['base table']);
           if (isset($entity_info[$name]['revision table'])) {
-            $entity_info[$name]['schema_fields_sql']['revision table'] = drupal_schema_fields_sql($entity_info[$name]['revision table']);
+            $entity_info[$name]['schema_fields_sql']['revision table'] = schema_fields_sql($entity_info[$name]['revision table']);
           }
         }
       }
       // Let other modules alter the entity info.
-      drupal_alter('entity_info', $entity_info);
+      alter('entity_info', $entity_info);
       cache()->set("entity_info:$langcode", $entity_info);
     }
   }
@@ -116,7 +118,7 @@ function entity_get_info($entity_type = NULL) {
  * Resets the cached information about entity types.
  */
 function entity_info_cache_clear() {
-  drupal_static_reset('entity_get_info');
+  drupal_static_reset('Drupal\entity_get_info');
   // Clear all languages.
   cache()->deletePrefix('entity_info:');
 }
@@ -198,12 +200,12 @@ function entity_create_stub_entity($entity_type, $ids) {
  * database access if loaded again during the same page request.
  *
  * The actual loading is done through a class that has to implement the
- * DrupalEntityControllerInterface interface. By default,
- * DrupalDefaultEntityController is used. Entity types can specify that a
+ * EntityControllerInterface interface. By default,
+ * DefaultEntityController is used. Entity types can specify that a
  * different class should be used by setting the 'controller class' key in
  * hook_entity_info(). These classes can either implement the
- * DrupalEntityControllerInterface interface, or, most commonly, extend the
- * DrupalDefaultEntityController class. See node_entity_info() and the
+ * EntityControllerInterface interface, or, most commonly, extend the
+ * DefaultEntityController class. See node_entity_info() and the
  * NodeController in node.module as an example.
  *
  * @param $entity_type
@@ -224,8 +226,8 @@ function entity_create_stub_entity($entity_type, $ids) {
  * @todo Remove $conditions in Drupal 8.
  *
  * @see hook_entity_info()
- * @see DrupalEntityControllerInterface
- * @see DrupalDefaultEntityController
+ * @see EntityControllerInterface
+ * @see DefaultEntityController
  * @see EntityFieldQuery
  */
 function entity_load($entity_type, $ids = FALSE, $conditions = array(), $reset = FALSE) {
@@ -283,7 +285,7 @@ function entity_delete_multiple($entity_type, $ids) {
  */
 function entity_create($entity_type, array $values) {
   $info = entity_get_info($entity_type) + array('entity class' => 'Entity');
-  $class = $info['entity class'];
+  $class = 'Drupal\\' . $info['entity class'];
   return new $class($values, $entity_type);
 }
 
@@ -294,7 +296,7 @@ function entity_get_controller($entity_type) {
   $controllers = &drupal_static(__FUNCTION__, array());
   if (!isset($controllers[$entity_type])) {
     $type_info = entity_get_info($entity_type);
-    $class = $type_info['controller class'];
+    $class = 'Drupal\\' . $type_info['controller class'];
     $controllers[$entity_type] = new $class($entity_type);
   }
   return $controllers[$entity_type];
@@ -375,7 +377,8 @@ function entity_uri($entity_type, $entity) {
 
   // Invoke the callback to get the URI. If there is no callback, return NULL.
   if (isset($uri_callback)) {
-    $uri = $uri_callback($entity);
+    $function = 'Drupal\\' . $uri_callback;
+    $uri = $function($entity);
     // Pass the entity data to url() so that alter functions do not need to
     // lookup this entity again.
     $uri['options']['entity_type'] = $entity_type;
@@ -405,7 +408,8 @@ function entity_label($entity_type, $entity) {
   $label = FALSE;
   $info = entity_get_info($entity_type);
   if (isset($info['label callback'])) {
-    $label = $info['label callback']($entity_type, $entity);
+    $function = 'Drupal\\' . $info['label callback'];
+    $label = $function($entity_type, $entity);
   }
   elseif (!empty($info['entity keys']['label']) && isset($entity->{$info['entity keys']['label']})) {
     $label = $entity->{$info['entity keys']['label']};
@@ -463,6 +467,7 @@ function entity_form_submit_build_entity($entity_type, $entity, $form, &$form_st
   // Invoke all specified builders for copying form values to entity properties.
   if (isset($form['#entity_builders'])) {
     foreach ($form['#entity_builders'] as $function) {
+      $function = 'Drupal\\' . $function;
       $function($entity_type, $entity, $form, $form_state);
     }
   }
diff --git a/core/modules/entity/entity.query.inc b/core/modules/entity/entity.query.inc
index d02d456..7ec775e 100644
--- a/core/modules/entity/entity.query.inc
+++ b/core/modules/entity/entity.query.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -734,7 +736,7 @@ class EntityFieldQuery {
    */
   public function execute() {
     // Give a chance to other modules to alter the query.
-    drupal_alter('entity_query', $this);
+    alter('entity_query', $this);
     $this->altered = TRUE;
 
     // Initialize the pager.
@@ -755,8 +757,9 @@ class EntityFieldQuery {
   public function queryCallback() {
     // Use the override from $this->executeCallback. It can be set either
     // while building the query, or using hook_entity_query_alter().
-    if (function_exists($this->executeCallback)) {
-      return $this->executeCallback;
+    $function = 'Drupal\\' . $this->executeCallback;
+    if (function_exists($function)) {
+      return $function;
     }
     // If there are no field conditions and sorts, and no execute callback
     // then we default to querying entity tables in SQL.
@@ -774,7 +777,7 @@ class EntityFieldQuery {
     }
     if ($storage) {
       // Use hook_field_storage_query() from the field storage.
-      return $storage . '_field_storage_query';
+      return 'Drupal\\' . $storage . '_field_storage_query';
     }
     else {
       throw new EntityFieldQueryException(t("Field storage engine not found."));
@@ -799,7 +802,7 @@ class EntityFieldQuery {
       throw new EntityFieldQueryException(t('Entity %entity has no base table.', array('%entity' => $entity_type)));
     }
     $base_table = $entity_info['base table'];
-    $base_table_schema = drupal_get_schema($base_table);
+    $base_table_schema = get_schema($base_table);
     $select_query = db_select($base_table);
     $select_query->addExpression(':entity_type', 'entity_type', array(':entity_type' => $entity_type));
     // Process the property conditions.
diff --git a/core/modules/entity/tests/entity.test b/core/modules/entity/tests/entity.test
index 35b6ab1..fa55dca 100644
--- a/core/modules/entity/tests/entity.test
+++ b/core/modules/entity/tests/entity.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -8,7 +9,7 @@
 /**
  * Tests the basic Entity API.
  */
-class EntityAPITestCase extends DrupalWebTestCase {
+class EntityAPITestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -70,7 +71,7 @@ class EntityAPITestCase extends DrupalWebTestCase {
 /**
  * Tests Entity API base functionality.
  */
-class EntityAPIInfoTestCase extends DrupalWebTestCase  {
+class EntityAPIInfoTestCase extends WebTestCase  {
 
   public static function getInfo() {
     return array(
@@ -91,7 +92,7 @@ class EntityAPIInfoTestCase extends DrupalWebTestCase  {
     // Change the label of the test entity type and make sure changes appear
     // after flushing caches.
     variable_set('entity_cache_test_label', 'New label.');
-    drupal_flush_all_caches();
+    flush_all_caches();
     $info = entity_get_info('entity_cache_test');
     $this->assertEqual($info['label'], 'New label.', 'New label appears in entity info.');
 
@@ -110,6 +111,6 @@ class EntityAPIInfoTestCase extends DrupalWebTestCase  {
     module_enable(array('entity_cache_test'));
     $info = variable_get('entity_cache_test');
     $this->assertEqual($info['label'], 'Entity Cache Test', 'Entity info label is correct.');
-    $this->assertEqual($info['controller class'], 'DrupalDefaultEntityController', 'Entity controller class info is correct.');
+    $this->assertEqual($info['controller class'], 'DefaultEntityController', 'Entity controller class info is correct.');
   }
 }
diff --git a/core/modules/entity/tests/entity_cache_test.module b/core/modules/entity/tests/entity_cache_test.module
index 5ae9ecc..7e37fbe 100644
--- a/core/modules/entity/tests/entity_cache_test.module
+++ b/core/modules/entity/tests/entity_cache_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/entity/tests/entity_cache_test_dependency.module b/core/modules/entity/tests/entity_cache_test_dependency.module
index 2d4b3be..1cf59ce 100644
--- a/core/modules/entity/tests/entity_cache_test_dependency.module
+++ b/core/modules/entity/tests/entity_cache_test_dependency.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/entity/tests/entity_crud_hook_test.module b/core/modules/entity/tests/entity_crud_hook_test.module
index 378c7b6..545220b 100644
--- a/core/modules/entity/tests/entity_crud_hook_test.module
+++ b/core/modules/entity/tests/entity_crud_hook_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/entity/tests/entity_crud_hook_test.test b/core/modules/entity/tests/entity_crud_hook_test.test
index 7c8e42e..78b094d 100644
--- a/core/modules/entity/tests/entity_crud_hook_test.test
+++ b/core/modules/entity/tests/entity_crud_hook_test.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -17,7 +18,7 @@
  * As well as all type-specific hooks, like hook_node_insert(),
  * hook_comment_update(), etc.
  */
-class EntityCrudHookTestCase extends DrupalWebTestCase {
+class EntityCrudHookTestCase extends WebTestCase {
 
   protected $ids = array();
 
@@ -93,18 +94,18 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
     comment_save($comment);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_comment_presave called',
-      'entity_crud_hook_test_entity_presave called for type comment',
-      'entity_crud_hook_test_comment_insert called',
-      'entity_crud_hook_test_entity_insert called for type comment',
+      'Drupal\entity_crud_hook_test_comment_presave called',
+      'Drupal\entity_crud_hook_test_entity_presave called for type comment',
+      'Drupal\entity_crud_hook_test_comment_insert called',
+      'Drupal\entity_crud_hook_test_entity_insert called for type comment',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
     $comment = comment_load($comment->cid);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_entity_load called for type comment',
-      'entity_crud_hook_test_comment_load called',
+      'Drupal\entity_crud_hook_test_entity_load called for type comment',
+      'Drupal\entity_crud_hook_test_comment_load called',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
@@ -112,20 +113,20 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
     comment_save($comment);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_comment_presave called',
-      'entity_crud_hook_test_entity_presave called for type comment',
-      'entity_crud_hook_test_comment_update called',
-      'entity_crud_hook_test_entity_update called for type comment',
+      'Drupal\entity_crud_hook_test_comment_presave called',
+      'Drupal\entity_crud_hook_test_entity_presave called for type comment',
+      'Drupal\entity_crud_hook_test_comment_update called',
+      'Drupal\entity_crud_hook_test_entity_update called for type comment',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
     comment_delete($comment->cid);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_comment_predelete called',
-      'entity_crud_hook_test_entity_predelete called for type comment',
-      'entity_crud_hook_test_comment_delete called',
-      'entity_crud_hook_test_entity_delete called for type comment',
+      'Drupal\entity_crud_hook_test_comment_predelete called',
+      'Drupal\entity_crud_hook_test_entity_predelete called for type comment',
+      'Drupal\entity_crud_hook_test_comment_delete called',
+      'Drupal\entity_crud_hook_test_entity_delete called for type comment',
     ));
   }
 
@@ -149,18 +150,18 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
     file_save($file);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_file_presave called',
-      'entity_crud_hook_test_entity_presave called for type file',
-      'entity_crud_hook_test_file_insert called',
-      'entity_crud_hook_test_entity_insert called for type file',
+      'Drupal\entity_crud_hook_test_file_presave called',
+      'Drupal\entity_crud_hook_test_entity_presave called for type file',
+      'Drupal\entity_crud_hook_test_file_insert called',
+      'Drupal\entity_crud_hook_test_entity_insert called for type file',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
     $file = file_load($file->fid);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_entity_load called for type file',
-      'entity_crud_hook_test_file_load called',
+      'Drupal\entity_crud_hook_test_entity_load called for type file',
+      'Drupal\entity_crud_hook_test_file_load called',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
@@ -168,20 +169,20 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
     file_save($file);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_file_presave called',
-      'entity_crud_hook_test_entity_presave called for type file',
-      'entity_crud_hook_test_file_update called',
-      'entity_crud_hook_test_entity_update called for type file',
+      'Drupal\entity_crud_hook_test_file_presave called',
+      'Drupal\entity_crud_hook_test_entity_presave called for type file',
+      'Drupal\entity_crud_hook_test_file_update called',
+      'Drupal\entity_crud_hook_test_entity_update called for type file',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
     file_delete($file);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_file_predelete called',
-      'entity_crud_hook_test_entity_predelete called for type file',
-      'entity_crud_hook_test_file_delete called',
-      'entity_crud_hook_test_entity_delete called for type file',
+      'Drupal\entity_crud_hook_test_file_predelete called',
+      'Drupal\entity_crud_hook_test_entity_predelete called for type file',
+      'Drupal\entity_crud_hook_test_file_delete called',
+      'Drupal\entity_crud_hook_test_entity_delete called for type file',
     ));
   }
 
@@ -205,18 +206,18 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
     node_save($node);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_node_presave called',
-      'entity_crud_hook_test_entity_presave called for type node',
-      'entity_crud_hook_test_node_insert called',
-      'entity_crud_hook_test_entity_insert called for type node',
+      'Drupal\entity_crud_hook_test_node_presave called',
+      'Drupal\entity_crud_hook_test_entity_presave called for type node',
+      'Drupal\entity_crud_hook_test_node_insert called',
+      'Drupal\entity_crud_hook_test_entity_insert called for type node',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
     $node = node_load($node->nid);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_entity_load called for type node',
-      'entity_crud_hook_test_node_load called',
+      'Drupal\entity_crud_hook_test_entity_load called for type node',
+      'Drupal\entity_crud_hook_test_node_load called',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
@@ -224,20 +225,20 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
     node_save($node);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_node_presave called',
-      'entity_crud_hook_test_entity_presave called for type node',
-      'entity_crud_hook_test_node_update called',
-      'entity_crud_hook_test_entity_update called for type node',
+      'Drupal\entity_crud_hook_test_node_presave called',
+      'Drupal\entity_crud_hook_test_entity_presave called for type node',
+      'Drupal\entity_crud_hook_test_node_update called',
+      'Drupal\entity_crud_hook_test_entity_update called for type node',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
     node_delete($node->nid);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_node_predelete called',
-      'entity_crud_hook_test_entity_predelete called for type node',
-      'entity_crud_hook_test_node_delete called',
-      'entity_crud_hook_test_entity_delete called for type node',
+      'Drupal\entity_crud_hook_test_node_predelete called',
+      'Drupal\entity_crud_hook_test_entity_predelete called for type node',
+      'Drupal\entity_crud_hook_test_node_delete called',
+      'Drupal\entity_crud_hook_test_entity_delete called for type node',
     ));
   }
 
@@ -263,18 +264,18 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
     taxonomy_term_save($term);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_taxonomy_term_presave called',
-      'entity_crud_hook_test_entity_presave called for type taxonomy_term',
-      'entity_crud_hook_test_taxonomy_term_insert called',
-      'entity_crud_hook_test_entity_insert called for type taxonomy_term',
+      'Drupal\entity_crud_hook_test_taxonomy_term_presave called',
+      'Drupal\entity_crud_hook_test_entity_presave called for type taxonomy_term',
+      'Drupal\entity_crud_hook_test_taxonomy_term_insert called',
+      'Drupal\entity_crud_hook_test_entity_insert called for type taxonomy_term',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
     $term = taxonomy_term_load($term->tid);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_entity_load called for type taxonomy_term',
-      'entity_crud_hook_test_taxonomy_term_load called',
+      'Drupal\entity_crud_hook_test_entity_load called for type taxonomy_term',
+      'Drupal\entity_crud_hook_test_taxonomy_term_load called',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
@@ -282,20 +283,20 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
     taxonomy_term_save($term);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_taxonomy_term_presave called',
-      'entity_crud_hook_test_entity_presave called for type taxonomy_term',
-      'entity_crud_hook_test_taxonomy_term_update called',
-      'entity_crud_hook_test_entity_update called for type taxonomy_term',
+      'Drupal\entity_crud_hook_test_taxonomy_term_presave called',
+      'Drupal\entity_crud_hook_test_entity_presave called for type taxonomy_term',
+      'Drupal\entity_crud_hook_test_taxonomy_term_update called',
+      'Drupal\entity_crud_hook_test_entity_update called for type taxonomy_term',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
     taxonomy_term_delete($term->tid);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_taxonomy_term_predelete called',
-      'entity_crud_hook_test_entity_predelete called for type taxonomy_term',
-      'entity_crud_hook_test_taxonomy_term_delete called',
-      'entity_crud_hook_test_entity_delete called for type taxonomy_term',
+      'Drupal\entity_crud_hook_test_taxonomy_term_predelete called',
+      'Drupal\entity_crud_hook_test_entity_predelete called for type taxonomy_term',
+      'Drupal\entity_crud_hook_test_taxonomy_term_delete called',
+      'Drupal\entity_crud_hook_test_entity_delete called for type taxonomy_term',
     ));
   }
 
@@ -313,18 +314,18 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
     taxonomy_vocabulary_save($vocabulary);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_taxonomy_vocabulary_presave called',
-      'entity_crud_hook_test_entity_presave called for type taxonomy_vocabulary',
-      'entity_crud_hook_test_taxonomy_vocabulary_insert called',
-      'entity_crud_hook_test_entity_insert called for type taxonomy_vocabulary',
+      'Drupal\entity_crud_hook_test_taxonomy_vocabulary_presave called',
+      'Drupal\entity_crud_hook_test_entity_presave called for type taxonomy_vocabulary',
+      'Drupal\entity_crud_hook_test_taxonomy_vocabulary_insert called',
+      'Drupal\entity_crud_hook_test_entity_insert called for type taxonomy_vocabulary',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
     $vocabulary = taxonomy_vocabulary_load($vocabulary->vid);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_entity_load called for type taxonomy_vocabulary',
-      'entity_crud_hook_test_taxonomy_vocabulary_load called',
+      'Drupal\entity_crud_hook_test_entity_load called for type taxonomy_vocabulary',
+      'Drupal\entity_crud_hook_test_taxonomy_vocabulary_load called',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
@@ -332,20 +333,20 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
     taxonomy_vocabulary_save($vocabulary);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_taxonomy_vocabulary_presave called',
-      'entity_crud_hook_test_entity_presave called for type taxonomy_vocabulary',
-      'entity_crud_hook_test_taxonomy_vocabulary_update called',
-      'entity_crud_hook_test_entity_update called for type taxonomy_vocabulary',
+      'Drupal\entity_crud_hook_test_taxonomy_vocabulary_presave called',
+      'Drupal\entity_crud_hook_test_entity_presave called for type taxonomy_vocabulary',
+      'Drupal\entity_crud_hook_test_taxonomy_vocabulary_update called',
+      'Drupal\entity_crud_hook_test_entity_update called for type taxonomy_vocabulary',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
     taxonomy_vocabulary_delete($vocabulary->vid);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_taxonomy_vocabulary_predelete called',
-      'entity_crud_hook_test_entity_predelete called for type taxonomy_vocabulary',
-      'entity_crud_hook_test_taxonomy_vocabulary_delete called',
-      'entity_crud_hook_test_entity_delete called for type taxonomy_vocabulary',
+      'Drupal\entity_crud_hook_test_taxonomy_vocabulary_predelete called',
+      'Drupal\entity_crud_hook_test_entity_predelete called for type taxonomy_vocabulary',
+      'Drupal\entity_crud_hook_test_taxonomy_vocabulary_delete called',
+      'Drupal\entity_crud_hook_test_entity_delete called for type taxonomy_vocabulary',
     ));
   }
 
@@ -365,18 +366,18 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
     $account = user_save($account, $edit);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_user_presave called',
-      'entity_crud_hook_test_entity_presave called for type user',
-      'entity_crud_hook_test_user_insert called',
-      'entity_crud_hook_test_entity_insert called for type user',
+      'Drupal\entity_crud_hook_test_user_presave called',
+      'Drupal\entity_crud_hook_test_entity_presave called for type user',
+      'Drupal\entity_crud_hook_test_user_insert called',
+      'Drupal\entity_crud_hook_test_entity_insert called for type user',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
     $account = user_load($account->uid);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_entity_load called for type user',
-      'entity_crud_hook_test_user_load called',
+      'Drupal\entity_crud_hook_test_entity_load called for type user',
+      'Drupal\entity_crud_hook_test_user_load called',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
@@ -384,20 +385,20 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
     $account = user_save($account, $edit);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_user_presave called',
-      'entity_crud_hook_test_entity_presave called for type user',
-      'entity_crud_hook_test_user_update called',
-      'entity_crud_hook_test_entity_update called for type user',
+      'Drupal\entity_crud_hook_test_user_presave called',
+      'Drupal\entity_crud_hook_test_entity_presave called for type user',
+      'Drupal\entity_crud_hook_test_user_update called',
+      'Drupal\entity_crud_hook_test_entity_update called for type user',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
     user_delete($account->uid);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_user_predelete called',
-      'entity_crud_hook_test_entity_predelete called for type user',
-      'entity_crud_hook_test_user_delete called',
-      'entity_crud_hook_test_entity_delete called for type user',
+      'Drupal\entity_crud_hook_test_user_predelete called',
+      'Drupal\entity_crud_hook_test_entity_predelete called for type user',
+      'Drupal\entity_crud_hook_test_user_delete called',
+      'Drupal\entity_crud_hook_test_entity_delete called for type user',
     ));
   }
 
diff --git a/core/modules/entity/tests/entity_query.test b/core/modules/entity/tests/entity_query.test
index 29642bc..a148860 100644
--- a/core/modules/entity/tests/entity_query.test
+++ b/core/modules/entity/tests/entity_query.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, stdClass;
 
 /**
  * @file
@@ -8,7 +10,7 @@
 /**
  * Tests EntityFieldQuery.
  */
-class EntityFieldQueryTestCase extends DrupalWebTestCase {
+class EntityFieldQueryTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -105,7 +107,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
       $entity->fttype = ($i < 5) ? 'bundle1' : 'bundle2';
 
       $entity->{$this->field_names[0]}[LANGUAGE_NONE][0]['value'] = $i;
-      drupal_write_record('test_entity_bundle_key', $entity);
+      write_record('test_entity_bundle_key', $entity);
       field_attach_insert('test_entity_bundle_key', $entity);
     }
 
@@ -116,7 +118,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
     $entity->{$this->field_names[1]}[LANGUAGE_NONE][0]['color'] = 'red';
     $entity->{$this->field_names[1]}[LANGUAGE_NONE][1]['shape'] = 'circle';
     $entity->{$this->field_names[1]}[LANGUAGE_NONE][1]['color'] = 'blue';
-    drupal_write_record('test_entity_bundle', $entity);
+    write_record('test_entity_bundle', $entity);
     field_attach_insert('test_entity_bundle', $entity);
 
     $instances[2] = $instance;
@@ -133,9 +135,9 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
       $entity->fttype = 'test_bundle';
       $entity->{$this->field_names[0]}[LANGUAGE_NONE][0]['value'] = $i;
 
-      drupal_write_record('test_entity', $entity);
+      write_record('test_entity', $entity);
       field_attach_insert('test_entity', $entity);
-      drupal_write_record('test_entity_revision', $entity);
+      write_record('test_entity_revision', $entity);
     }
 
     // Add two revisions to an entity.
@@ -146,8 +148,8 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
       $entity->fttype = 'test_bundle';
       $entity->{$this->field_names[0]}[LANGUAGE_NONE][0]['value'] = $i;
 
-      drupal_write_record('test_entity', $entity, 'ftid');
-      drupal_write_record('test_entity_revision', $entity);
+      write_record('test_entity', $entity, 'ftid');
+      write_record('test_entity_revision', $entity);
 
       db_update('test_entity')
        ->fields(array('ftvid' => $entity->ftvid))
@@ -982,7 +984,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
       $entity->ftid = $i;
       $entity->fttype = 'test_entity_bundle';
       $entity->{$this->field_names[0]}[LANGUAGE_NONE][0]['value'] = $i - 5;
-      drupal_write_record('test_entity_bundle', $entity);
+      write_record('test_entity_bundle', $entity);
       field_attach_insert('test_entity_bundle', $entity);
     }
 
@@ -1225,14 +1227,14 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
     // Field-only query.
     $query = new EntityFieldQuery();
     $query->fieldCondition($this->fields[0], 'value', '3');
-    $this->assertIdentical($query->queryCallback(), 'field_sql_storage_field_storage_query', t('Pure field queries are handled by the Field storage handler.'));
+    $this->assertIdentical($query->queryCallback(), 'Drupal\field_sql_storage_field_storage_query', t('Pure field queries are handled by the Field storage handler.'));
 
     // Mixed entity and field query.
     $query = new EntityFieldQuery();
     $query
       ->entityCondition('entity_type', 'test_entity_bundle_key')
       ->fieldCondition($this->fields[0], 'value', '3');
-    $this->assertIdentical($query->queryCallback(), 'field_sql_storage_field_storage_query', t('Mixed queries are handled by the Field storage handler.'));
+    $this->assertIdentical($query->queryCallback(), 'Drupal\field_sql_storage_field_storage_query', t('Mixed queries are handled by the Field storage handler.'));
 
     // Overriding with $query->executeCallback.
     $query = new EntityFieldQuery();
diff --git a/core/modules/entity/tests/entity_test.install b/core/modules/entity/tests/entity_test.install
index ec2e5bd..77af593 100644
--- a/core/modules/entity/tests/entity_test.install
+++ b/core/modules/entity/tests/entity_test.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/entity/tests/entity_test.module b/core/modules/entity/tests/entity_test.module
index 6034b06..0157ef4 100644
--- a/core/modules/entity/tests/entity_test.module
+++ b/core/modules/entity/tests/entity_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php
index 329cf16..03d2da9 100644
--- a/core/modules/field/field.api.php
+++ b/core/modules/field/field.api.php
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @ingroup hooks
@@ -552,7 +554,7 @@ function hook_field_storage_update_field($field, $prior_field, $has_data) {
     // an example of what to do to modify the schema in place, preserving the
     // old data as much as possible.
   }
-  drupal_get_schema(NULL, TRUE);
+  get_schema(NULL, TRUE);
 }
 
 /**
@@ -1238,7 +1240,7 @@ function hook_field_attach_validate($entity_type, $entity, &$errors) {
 function hook_field_attach_submit($entity_type, $entity, $form, &$form_state) {
   // Sample case of an 'Empty the field' checkbox added on the form, allowing
   // a given field to be emptied.
-  $values = drupal_array_get_nested_value($form_state['values'], $form['#parents']);
+  $values = array_get_nested_value($form_state['values'], $form['#parents']);
   if (!empty($values['empty_field_foo'])) {
     unset($entity->field_foo);
   }
@@ -1978,7 +1980,7 @@ function hook_field_storage_create_field($field) {
   foreach ($schema as $name => $table) {
     db_create_table($name, $table);
   }
-  drupal_get_schema(NULL, TRUE);
+  get_schema(NULL, TRUE);
 }
 
 /**
@@ -2005,7 +2007,7 @@ function hook_field_storage_delete_field($field) {
   $revision_new_table = _field_sql_storage_revision_tablename($field);
   db_rename_table($table, $new_table);
   db_rename_table($revision_table, $revision_new_table);
-  drupal_get_schema(NULL, TRUE);
+  get_schema(NULL, TRUE);
 }
 
 /**
@@ -2426,7 +2428,7 @@ function hook_field_update_forbid($field, $prior_field, $has_data) {
  */
 function hook_field_update_field($field, $prior_field, $has_data) {
   // Reset the static value that keeps track of allowed values for list fields.
-  drupal_static_reset('list_allowed_values');
+  drupal_static_reset('Drupal\list_allowed_values');
 }
 
 /**
diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc
index c61ef52..f974a86 100644
--- a/core/modules/field/field.attach.inc
+++ b/core/modules/field/field.attach.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -198,7 +200,7 @@ function _field_invoke($op, $entity_type, $entity, &$a = NULL, &$b = NULL, $opti
     // field_info_field_by_id().
     $field = field_info_field_by_id($instance['field_id']);
     $field_name = $field['field_name'];
-    $function = $options['default'] ? 'field_default_' . $op : $field['module'] . '_field_' . $op;
+    $function = 'Drupal\\' . ($options['default'] ? 'field_default_' . $op : $field['module'] . '_field_' . $op);
     if (function_exists($function)) {
       // Determine the list of languages to iterate on.
       $available_languages = field_available_languages($entity_type, $field);
@@ -308,7 +310,7 @@ function _field_invoke_multiple($op, $entity_type, $entities, &$a = NULL, &$b =
       $field_id = $instance['field_id'];
       $field_name = $instance['field_name'];
       $field = $field_info[$field_id];
-      $function = $options['default'] ? 'field_default_' . $op : $field['module'] . '_field_' . $op;
+      $function = $options['default'] ? ('Drupal\field_default_' . $op) : ('Drupal\\' . $field['module'] . '_field_' . $op);
       if (function_exists($function)) {
         // Add the field to the list of fields to invoke the hook on.
         if (!isset($fields[$field_id])) {
@@ -337,7 +339,7 @@ function _field_invoke_multiple($op, $entity_type, $entities, &$a = NULL, &$b =
   // For each field, invoke the field hook and collect results.
   foreach ($fields as $field_id => $field) {
     $field_name = $field['field_name'];
-    $function = $options['default'] ? 'field_default_' . $op : $field['module'] . '_field_' . $op;
+    $function = $options['default'] ? ('Drupal\field_default_' . $op) : ('Drupal\\' . $field['module'] . '_field_' . $op);
     // Iterate over all the field translations.
     foreach ($grouped_items[$field_id] as $langcode => &$items) {
       $entities = $grouped_entities[$field_id][$langcode];
@@ -576,7 +578,7 @@ function field_attach_form($entity_type, $entity, &$form, &$form_state, $langcod
   // Let other modules make changes to the form.
   // Avoid module_invoke_all() to let parameters be taken by reference.
   foreach (module_implements('field_attach_form') as $module) {
-    $function = $module . '_field_attach_form';
+    $function = 'Drupal\\' . $module . '_field_attach_form';
     $function($entity_type, $entity, $form, $form_state, $langcode);
   }
 }
@@ -671,7 +673,7 @@ function field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $
     // data before the storage engine, accumulating along the way.
     $skip_fields = array();
     foreach (module_implements('field_storage_pre_load') as $module) {
-      $function = $module . '_field_storage_pre_load';
+      $function = 'Drupal\\' . $module . '_field_storage_pre_load';
       $function($entity_type, $queried_entities, $age, $skip_fields, $options);
     }
 
@@ -780,7 +782,7 @@ function field_attach_validate($entity_type, $entity) {
   // Let other modules validate the entity.
   // Avoid module_invoke_all() to let $errors be taken by reference.
   foreach (module_implements('field_attach_validate') as $module) {
-    $function = $module . '_field_attach_validate';
+    $function = 'Drupal\\' . $module . '_field_attach_validate';
     $function($entity_type, $entity, $errors);
   }
 
@@ -867,7 +869,7 @@ function field_attach_submit($entity_type, $entity, $form, &$form_state) {
   // Let other modules act on submitting the entity.
   // Avoid module_invoke_all() to let $form_state be taken by reference.
   foreach (module_implements('field_attach_submit') as $module) {
-    $function = $module . '_field_attach_submit';
+    $function = 'Drupal\\' . $module . '_field_attach_submit';
     $function($entity_type, $entity, $form, $form_state);
   }
 }
@@ -916,7 +918,7 @@ function field_attach_insert($entity_type, $entity) {
   // saved fields along the way.
   $skip_fields = array();
   foreach (module_implements('field_storage_pre_insert') as $module) {
-    $function = $module . '_field_storage_pre_insert';
+    $function = 'Drupal\\' . $module . '_field_storage_pre_insert';
     $function($entity_type, $entity, $skip_fields);
   }
 
@@ -963,7 +965,7 @@ function field_attach_update($entity_type, $entity) {
   // saved fields along the way.
   $skip_fields = array();
   foreach (module_implements('field_storage_pre_update') as $module) {
-    $function = $module . '_field_storage_pre_update';
+    $function = 'Drupal\\' . $module . '_field_storage_pre_update';
     $function($entity_type, $entity, $skip_fields);
   }
 
@@ -1194,7 +1196,7 @@ function field_attach_view($entity_type, $entity, $view_mode, $langcode = NULL)
     'display' => $view_mode,
     'language' => $langcode,
   );
-  drupal_alter('field_attach_view', $output, $context);
+  alter('field_attach_view', $output, $context);
 
   // Reset the _field_view_prepared flag set in field_attach_prepare_view(),
   // in case the same entity is displayed with different settings later in
@@ -1239,7 +1241,7 @@ function field_attach_preprocess($entity_type, $entity, $element, &$variables) {
     'entity' => $entity,
     'element' => $element,
   );
-  drupal_alter('field_attach_preprocess', $variables, $context);
+  alter('field_attach_preprocess', $variables, $context);
 }
 
 /**
@@ -1278,7 +1280,7 @@ function field_attach_prepare_translation($entity_type, $entity, $langcode, $sou
     'source_entity' => $source_entity,
     'source_langcode' => $source_langcode,
   );
-  drupal_alter('field_attach_prepare_translation', $entity, $context);
+  alter('field_attach_prepare_translation', $entity, $context);
 }
 
 /**
diff --git a/core/modules/field/field.crud.inc b/core/modules/field/field.crud.inc
index 6df3235..75b8273 100644
--- a/core/modules/field/field.crud.inc
+++ b/core/modules/field/field.crud.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, PDO, stdClass;
 
 /**
  * @file
@@ -169,14 +171,14 @@ function field_create_field($field) {
   );
 
   // Store the field and get the id back.
-  drupal_write_record('field_config', $record);
+  write_record('field_config', $record);
   $field['id'] = $record['id'];
 
   // Invoke hook_field_storage_create_field after the field is
   // complete (e.g. it has its id).
   try {
     // Invoke hook_field_storage_create_field after
-    // drupal_write_record() sets the field id.
+    // write_record() sets the field id.
     module_invoke($storage_type['module'], 'field_storage_create_field', $field);
   }
   catch (Exception $e) {
@@ -258,7 +260,7 @@ function field_update_field($field) {
 
   // See if any module forbids the update by throwing an exception.
   foreach (module_implements('field_update_forbid') as $module) {
-    $function = $module . '_field_update_forbid';
+    $function = 'Drupal\\' . $module . '_field_update_forbid';
     $function($field, $prior_field, $has_data);
   }
 
@@ -283,7 +285,7 @@ function field_update_field($field) {
 
   // Store the field and create the id.
   $primary_key = array('id');
-  drupal_write_record('field_config', $field, $primary_key);
+  write_record('field_config', $field, $primary_key);
 
   // Clear caches
   field_cache_clear(TRUE);
@@ -632,7 +634,7 @@ function _field_write_instance($instance, $update = FALSE) {
   else {
     $primary_key = array();
   }
-  drupal_write_record('field_config_instance', $record, $primary_key);
+  write_record('field_config_instance', $record, $primary_key);
 }
 
 /**
@@ -913,7 +915,7 @@ function field_purge_data($entity_type, $entity, $field, $instance) {
 
   // Let other modules act on purging the data.
   foreach (module_implements('field_attach_purge') as $module) {
-    $function = $module . '_field_attach_purge';
+    $function = 'Drupal\\' . $module . '_field_attach_purge';
     $function($entity_type, $entity, $field, $instance);
   }
 }
diff --git a/core/modules/field/field.default.inc b/core/modules/field/field.default.inc
index cb49bdb..da4f161 100644
--- a/core/modules/field/field.default.inc
+++ b/core/modules/field/field.default.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -35,7 +36,7 @@
 function field_default_extract_form_values($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state) {
   $path = array_merge($form['#parents'], array($field['field_name'], $langcode));
   $key_exists = NULL;
-  $values = drupal_array_get_nested_value($form_state['values'], $path, $key_exists);
+  $values = array_get_nested_value($form_state['values'], $path, $key_exists);
   if ($key_exists) {
     // Remove the 'value' of the 'add more' button.
     unset($values['add_more']);
@@ -160,7 +161,7 @@ function field_default_prepare_view($entity_type, $entities, $field, $instances,
 
   foreach ($modules as $module) {
     // Invoke hook_field_formatter_prepare_view().
-    $function = $module . '_field_formatter_prepare_view';
+    $function = 'Drupal\\' . $module . '_field_formatter_prepare_view';
     if (function_exists($function)) {
       $function($entity_type, $grouped_entities[$module], $field, $grouped_instances[$module], $langcode, $grouped_items[$module], $grouped_displays[$module]);
     }
@@ -205,7 +206,7 @@ function field_default_view($entity_type, $entity, $field, $instance, $langcode,
   if ($display['type'] !== 'hidden') {
     // Calling the formatter function through module_invoke() can have a
     // performance impact on pages with many fields and values.
-    $function = $display['module'] . '_field_formatter_view';
+    $function = 'Drupal\\' . $display['module'] . '_field_formatter_view';
     if (function_exists($function)) {
       $elements = $function($entity_type, $entity, $field, $instance, $langcode, $items, $display);
 
diff --git a/core/modules/field/field.form.inc b/core/modules/field/field.form.inc
index be3685d..69d2d3c 100644
--- a/core/modules/field/field.form.inc
+++ b/core/modules/field/field.form.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -33,7 +34,7 @@ function field_default_form($entity_type, $entity, $field, $instance, $langcode,
     'field' => $field,
     'instance' => $instance,
   );
-  drupal_alter(array('field_widget_properties', 'field_widget_properties_' . $entity_type), $instance['widget'], $context);
+  alter(array('field_widget_properties', 'field_widget_properties_' . $entity_type), $instance['widget'], $context);
 
   // Collect widget elements.
   $elements = array();
@@ -60,7 +61,7 @@ function field_default_form($entity_type, $entity, $field, $instance, $langcode,
     // make it the $delta value.
     else {
       $delta = isset($get_delta) ? $get_delta : 0;
-      $function = $instance['widget']['module'] . '_field_widget_form';
+      $function = 'Drupal\\' . $instance['widget']['module'] . '_field_widget_form';
       if (function_exists($function)) {
         $element = array(
           '#entity_type' => $instance['entity_type'],
@@ -85,7 +86,7 @@ function field_default_form($entity_type, $entity, $field, $instance, $langcode,
             'items' => $items,
             'delta' => $delta,
           );
-          drupal_alter(array('field_widget_form', 'field_widget_' . $instance['widget']['type'] . '_form'), $element, $form_state, $context);
+          alter(array('field_widget_form', 'field_widget_' . $instance['widget']['type'] . '_form'), $element, $form_state, $context);
 
           // If we're processing a specific delta value for a field where the
           // field module handles multiples, set the delta in the result.
@@ -110,9 +111,9 @@ function field_default_form($entity_type, $entity, $field, $instance, $langcode,
       '#type' => 'container',
       '#attributes' => array(
         'class' => array(
-          'field-type-' . drupal_html_class($field['type']),
-          'field-name-' . drupal_html_class($field_name),
-          'field-widget-' . drupal_html_class($instance['widget']['type']),
+          'field-type-' . html_class($field['type']),
+          'field-name-' . html_class($field_name),
+          'field-widget-' . html_class($instance['widget']['type']),
         ),
       ),
       '#weight' => $instance['widget']['weight'],
@@ -166,11 +167,11 @@ function field_multiple_value_form($field, $instance, $langcode, $items, &$form,
   $description = field_filter_xss($instance['description']);
 
   $id_prefix = implode('-', array_merge($parents, array($field_name)));
-  $wrapper_id = drupal_html_id($id_prefix . '-add-more-wrapper');
+  $wrapper_id = html_id($id_prefix . '-add-more-wrapper');
 
   $field_elements = array();
 
-  $function = $instance['widget']['module'] . '_field_widget_form';
+  $function = 'Drupal\\' . $instance['widget']['module'] . '_field_widget_form';
   if (function_exists($function)) {
     for ($delta = 0; $delta <= $max; $delta++) {
       $multiple = $field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED;
@@ -214,7 +215,7 @@ function field_multiple_value_form($field, $instance, $langcode, $items, &$form,
           'items' => $items,
           'delta' => $delta,
         );
-        drupal_alter(array('field_widget_form', 'field_widget_' . $instance['widget']['type'] . '_form'), $element, $form_state, $context);
+        alter(array('field_widget_form', 'field_widget_' . $instance['widget']['type'] . '_form'), $element, $form_state, $context);
 
         $field_elements[$delta] = $element;
       }
@@ -271,7 +272,7 @@ function theme_field_multiple_value_form($variables) {
   $output = '';
 
   if ($element['#cardinality'] > 1 || $element['#cardinality'] == FIELD_CARDINALITY_UNLIMITED) {
-    $table_id = drupal_html_id($element['#field_name'] . '_values');
+    $table_id = html_id($element['#field_name'] . '_values');
     $order_class = $element['#field_name'] . '-delta-order';
     $required = !empty($element['#required']) ? theme('form_required_marker', $variables) : '';
 
@@ -296,7 +297,7 @@ function theme_field_multiple_value_form($variables) {
         $items[] = &$element[$key];
       }
     }
-    usort($items, '_field_sort_items_value_helper');
+    usort($items, 'Drupal\_field_sort_items_value_helper');
 
     // Add the items as table rows.
     foreach ($items as $key => $item) {
@@ -319,7 +320,7 @@ function theme_field_multiple_value_form($variables) {
     $output .= '<div class="clearfix">' . drupal_render($add_more_button) . '</div>';
     $output .= '</div>';
 
-    drupal_add_tabledrag($table_id, 'order', 'sibling', $order_class);
+    add_tabledrag($table_id, 'order', 'sibling', $order_class);
   }
   else {
     foreach (element_children($element) as $key) {
@@ -358,11 +359,11 @@ function field_default_form_errors($entity_type, $entity, $field, $instance, $la
   $field_state = field_form_get_state($form['#parents'], $field['field_name'], $langcode, $form_state);
 
   if (!empty($field_state['errors'])) {
-    $function = $instance['widget']['module'] . '_field_widget_error';
+    $function = 'Drupal\\' . $instance['widget']['module'] . '_field_widget_error';
     $function_exists = function_exists($function);
 
     // Locate the correct element in the the form.
-    $element = drupal_array_get_nested_value($form_state['complete_form'], $field_state['array_parents']);
+    $element = array_get_nested_value($form_state['complete_form'], $field_state['array_parents']);
 
     $multiple_widget = field_behaviors_widget('multiple values', $instance) != FIELD_BEHAVIOR_DEFAULT;
     foreach ($field_state['errors'] as $delta => $delta_errors) {
@@ -399,7 +400,7 @@ function field_add_more_submit($form, &$form_state) {
   $button = $form_state['triggering_element'];
 
   // Go one level up in the form, to the widgets container.
-  $element = drupal_array_get_nested_value($form, array_slice($button['#array_parents'], 0, -1));
+  $element = array_get_nested_value($form, array_slice($button['#array_parents'], 0, -1));
   $field_name = $element['#field_name'];
   $langcode = $element['#language'];
   $parents = $element['#field_parents'];
@@ -424,7 +425,7 @@ function field_add_more_js($form, $form_state) {
   $button = $form_state['triggering_element'];
 
   // Go one level up in the form, to the widgets container.
-  $element = drupal_array_get_nested_value($form, array_slice($button['#array_parents'], 0, -1));
+  $element = array_get_nested_value($form, array_slice($button['#array_parents'], 0, -1));
   $field_name = $element['#field_name'];
   $langcode = $element['#language'];
   $parents = $element['#field_parents'];
@@ -470,7 +471,7 @@ function field_add_more_js($form, $form_state) {
  */
 function field_form_get_state($parents, $field_name, $langcode, &$form_state) {
   $form_state_parents = _field_form_state_parents($parents, $field_name, $langcode);
-  return drupal_array_get_nested_value($form_state, $form_state_parents);
+  return array_get_nested_value($form_state, $form_state_parents);
 }
 
 /**
@@ -492,7 +493,7 @@ function field_form_get_state($parents, $field_name, $langcode, &$form_state) {
  */
 function field_form_set_state($parents, $field_name, $langcode, &$form_state, $field_state) {
   $form_state_parents = _field_form_state_parents($parents, $field_name, $langcode);
-  drupal_array_set_nested_value($form_state, $form_state_parents, $field_state);
+  array_set_nested_value($form_state, $form_state_parents, $field_state);
 }
 
 /**
diff --git a/core/modules/field/field.info.inc b/core/modules/field/field.info.inc
index af7d93d..b9697ef 100644
--- a/core/modules/field/field.info.inc
+++ b/core/modules/field/field.info.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -26,8 +27,8 @@
  * are affected.
  */
 function field_info_cache_clear() {
-  drupal_static_reset('field_view_mode_settings');
-  drupal_static_reset('field_available_languages');
+  drupal_static_reset('Drupal\field_view_mode_settings');
+  drupal_static_reset('Drupal\field_available_languages');
 
   // @todo: Remove this when field_attach_*_bundle() bundle management
   // functions are moved to the entity API.
@@ -70,12 +71,12 @@ function _field_info_collate_types() {
   global $language;
 
   // Use the advanced drupal_static() pattern, since this is called very often.
-  static $drupal_static_fast;
+  static $static_fast;
 
-  if (!isset($drupal_static_fast)) {
-    $drupal_static_fast['field_info_collate_types'] = &drupal_static(__FUNCTION__);
+  if (!isset($static_fast)) {
+    $static_fast['field_info_collate_types'] = &drupal_static(__FUNCTION__);
   }
-  $info = &$drupal_static_fast['field_info_collate_types'];
+  $info = &$static_fast['field_info_collate_types'];
 
   // The _info() hooks invoked below include translated strings, so each
   // language is cached separately.
@@ -106,7 +107,7 @@ function _field_info_collate_types() {
           $info['field types'][$name]['module'] = $module;
         }
       }
-      drupal_alter('field_info', $info['field types']);
+      alter('field_info', $info['field types']);
 
       // Populate widget types.
       foreach (module_implements('field_widget_info') as $module) {
@@ -120,7 +121,7 @@ function _field_info_collate_types() {
           $info['widget types'][$name]['module'] = $module;
         }
       }
-      drupal_alter('field_widget_info', $info['widget types']);
+      alter('field_widget_info', $info['widget types']);
 
       // Populate formatter types.
       foreach (module_implements('field_formatter_info') as $module) {
@@ -134,7 +135,7 @@ function _field_info_collate_types() {
           $info['formatter types'][$name]['module'] = $module;
         }
       }
-      drupal_alter('field_formatter_info', $info['formatter types']);
+      alter('field_formatter_info', $info['formatter types']);
 
       // Populate storage types.
       foreach (module_implements('field_storage_info') as $module) {
@@ -148,7 +149,7 @@ function _field_info_collate_types() {
           $info['storage types'][$name]['module'] = $module;
         }
       }
-      drupal_alter('field_storage_info', $info['storage types']);
+      alter('field_storage_info', $info['storage types']);
 
       cache('field')->set("field_info_types:$langcode", $info);
     }
@@ -161,7 +162,7 @@ function _field_info_collate_types() {
  * Clear collated information on field and widget types and related structures.
  */
 function _field_info_collate_types_reset() {
-  drupal_static_reset('_field_info_collate_types');
+  drupal_static_reset('Drupal\_field_info_collate_types');
   // Clear all languages.
   cache('field')->deletePrefix('field_info_types:');
 }
@@ -185,12 +186,12 @@ function _field_info_collate_types_reset() {
  */
 function _field_info_collate_fields() {
   // Use the advanced drupal_static() pattern, since this is called very often.
-  static $drupal_static_fast;
+  static $static_fast;
 
-  if (!isset($drupal_static_fast)) {
-    $drupal_static_fast['field_info_collate_fields'] = &drupal_static(__FUNCTION__);
+  if (!isset($static_fast)) {
+    $static_fast['field_info_collate_fields'] = &drupal_static(__FUNCTION__);
   }
-  $info = &$drupal_static_fast['field_info_collate_fields'];
+  $info = &$static_fast['field_info_collate_fields'];
 
   if (!isset($info)) {
     if ($cached = cache('field')->get('field_info_fields')) {
@@ -236,7 +237,7 @@ function _field_info_collate_fields() {
 
       // Populate 'extra_fields'.
       $extra = module_invoke_all('field_extra_fields');
-      drupal_alter('field_extra_fields', $extra);
+      alter('field_extra_fields', $extra);
       // Merge in saved settings.
       foreach ($extra as $entity_type => $bundles) {
         foreach ($bundles as $bundle => $extra_fields) {
@@ -256,7 +257,7 @@ function _field_info_collate_fields() {
  * Clear collated information on existing fields and instances.
  */
 function _field_info_collate_fields_reset() {
-  drupal_static_reset('_field_info_collate_fields');
+  drupal_static_reset('Drupal\_field_info_collate_fields');
   cache('field')->delete('field_info_fields');
 }
 
@@ -276,7 +277,7 @@ function _field_info_prepare_field($field) {
 
   // Add storage details.
   $details = (array) module_invoke($field['storage']['module'], 'field_storage_details', $field);
-  drupal_alter('field_storage_details', $details, $field, $instance);
+  alter('field_storage_details', $details, $field, $instance);
   $field['storage']['details'] = $details;
 
   // Initialize the 'bundles' list.
diff --git a/core/modules/field/field.install b/core/modules/field/field.install
index 16b09e1..cbdc285 100644
--- a/core/modules/field/field.install
+++ b/core/modules/field/field.install
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, PDO;
 
 /**
  * @file
@@ -162,7 +164,7 @@ function field_schema() {
       'deleted' => array('deleted'),
     ),
   );
-  $schema['cache_field'] = drupal_get_schema_unprocessed('system', 'cache');
+  $schema['cache_field'] = get_schema_unprocessed('system', 'cache');
 
   return $schema;
 }
@@ -228,7 +230,7 @@ function _update_7000_field_create_field(&$field) {
     'translatable' => (int) $field['translatable'],
     'deleted' => (int) $field['deleted'],
   );
-  // We don't use drupal_write_record() here because it depends on the schema.
+  // We don't use write_record() here because it depends on the schema.
   $field['id'] = db_insert('field_config')
     ->fields($record)
     ->execute();
diff --git a/core/modules/field/field.module b/core/modules/field/field.module
index 9129fd5..9e5b30d 100644
--- a/core/modules/field/field.module
+++ b/core/modules/field/field.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 /**
  * @file
  * Attach custom data fields to Drupal entities.
@@ -17,12 +19,12 @@ class FieldException extends Exception {}
  * mechanism for auto-loading core APIs, so we have to load them on
  * every page request.
  */
-require_once DRUPAL_ROOT . '/core/modules/field/field.crud.inc';
-require_once DRUPAL_ROOT . '/core/modules/field/field.default.inc';
-require_once DRUPAL_ROOT . '/core/modules/field/field.info.inc';
-require_once DRUPAL_ROOT . '/core/modules/field/field.multilingual.inc';
-require_once DRUPAL_ROOT . '/core/modules/field/field.attach.inc';
-require_once DRUPAL_ROOT . '/core/modules/field/field.form.inc';
+require_once ROOT . '/core/modules/field/field.crud.inc';
+require_once ROOT . '/core/modules/field/field.default.inc';
+require_once ROOT . '/core/modules/field/field.info.inc';
+require_once ROOT . '/core/modules/field/field.multilingual.inc';
+require_once ROOT . '/core/modules/field/field.attach.inc';
+require_once ROOT . '/core/modules/field/field.form.inc';
 
 /**
  * @defgroup field Field API
@@ -482,7 +484,7 @@ function field_associate_fields($module) {
 function field_get_default_value($entity_type, $entity, $field, $instance, $langcode = NULL) {
   $items = array();
   if (!empty($instance['default_value_function'])) {
-    $function = $instance['default_value_function'];
+    $function = 'Drupal\\' . $instance['default_value_function'];
     $items = $function($entity_type, $entity, $field, $instance, $langcode);
   }
   elseif (!empty($instance['default_value'])) {
@@ -504,7 +506,7 @@ function field_get_default_value($entity_type, $entity, $field, $instance, $lang
  *   the array keys to ensure sequential deltas.
  */
 function _field_filter_items($field, $items) {
-  $function = $field['module'] . '_field_is_empty';
+  $function = 'Drupal\\' . $field['module'] . '_field_is_empty';
   foreach ((array) $items as $delta => $item) {
     // Explicitly break if the function is undefined.
     if ($function($item, $field)) {
@@ -520,7 +522,7 @@ function _field_filter_items($field, $items) {
  */
 function _field_sort_items($field, $items) {
   if (($field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED) && isset($items[0]['_weight'])) {
-    usort($items, '_field_sort_items_helper');
+    usort($items, 'Drupal\_field_sort_items_helper');
     foreach ($items as $delta => $item) {
       if (is_array($items[$delta])) {
         unset($items[$delta]['_weight']);
@@ -682,7 +684,7 @@ function field_get_display($instance, $view_mode, $entity) {
     'entity' => $entity,
     'view_mode' => $view_mode,
   );
-  drupal_alter(array('field_display', 'field_display_' . $instance['entity_type']), $display, $context);
+  alter(array('field_display', 'field_display_' . $instance['entity_type']), $display, $context);
 
   return $display;
 }
@@ -718,7 +720,7 @@ function field_extra_fields_get_display($entity_type, $bundle, $view_mode) {
     'bundle' => $bundle,
     'view_mode' => $view_mode,
   );
-  drupal_alter('field_extra_fields_display', $displays, $context);
+  alter('field_extra_fields_display', $displays, $context);
 
   return $displays;
 }
@@ -924,7 +926,7 @@ function field_view_field($entity_type, $entity, $field_name, $display = array()
       'view_mode' => '_custom',
       'display' => $display,
     );
-    drupal_alter('field_attach_view', $result, $context);
+    alter('field_attach_view', $result, $context);
 
     if (isset($result[$field_name])) {
       $output = $result[$field_name];
@@ -1001,7 +1003,7 @@ function field_access($op, $field, $entity_type, $entity = NULL, $account = NULL
   }
 
   foreach (module_implements('field_access') as $module) {
-    $function = $module . '_field_access';
+    $function = 'Drupal\\' . $module . '_field_access';
     $access = $function($op, $field, $entity_type, $entity, $account);
     if ($access === FALSE) {
       return FALSE;
@@ -1064,7 +1066,7 @@ function template_preprocess_field(&$variables, $hook) {
 
   // Add default CSS classes. Since there can be many fields rendered on a page,
   // save some overhead by calling strtr() directly instead of
-  // drupal_html_class().
+  // html_class().
   $variables['field_name_css'] = strtr($element['#field_name'], '_', '-');
   $variables['field_type_css'] = strtr($element['#field_type'], '_', '-');
   $variables['classes_array'] = array(
@@ -1097,15 +1099,15 @@ function template_preprocess_field(&$variables, $hook) {
 function template_process_field(&$variables, $hook) {
   // The default theme implementation is a function, so template_process() does
   // not automatically run, so we need to flatten the classes and attributes
-  // here. For best performance, only call drupal_attributes() when needed, and
+  // here. For best performance, only call attributes() when needed, and
   // note that template_preprocess_field() does not initialize the
   // *_attributes_array variables.
   $variables['classes'] = implode(' ', $variables['classes_array']);
-  $variables['attributes'] = empty($variables['attributes_array']) ? '' : drupal_attributes($variables['attributes_array']);
-  $variables['title_attributes'] = empty($variables['title_attributes_array']) ? '' : drupal_attributes($variables['title_attributes_array']);
-  $variables['content_attributes'] = empty($variables['content_attributes_array']) ? '' : drupal_attributes($variables['content_attributes_array']);
+  $variables['attributes'] = empty($variables['attributes_array']) ? '' : attributes($variables['attributes_array']);
+  $variables['title_attributes'] = empty($variables['title_attributes_array']) ? '' : attributes($variables['title_attributes_array']);
+  $variables['content_attributes'] = empty($variables['content_attributes_array']) ? '' : attributes($variables['content_attributes_array']);
   foreach ($variables['items'] as $delta => $item) {
-    $variables['item_attributes'][$delta] = empty($variables['item_attributes_array'][$delta]) ? '' : drupal_attributes($variables['item_attributes_array'][$delta]);
+    $variables['item_attributes'][$delta] = empty($variables['item_attributes_array'][$delta]) ? '' : attributes($variables['item_attributes_array'][$delta]);
   }
 }
 /**
diff --git a/core/modules/field/field.multilingual.inc b/core/modules/field/field.multilingual.inc
index 978db61..c2ba5d7 100644
--- a/core/modules/field/field.multilingual.inc
+++ b/core/modules/field/field.multilingual.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -101,11 +102,11 @@ function field_language_delete() {
  *   An array of valid language codes.
  */
 function field_available_languages($entity_type, $field) {
-  static $drupal_static_fast;
-  if (!isset($drupal_static_fast)) {
-    $drupal_static_fast['field_languages'] = &drupal_static(__FUNCTION__);
+  static $static_fast;
+  if (!isset($static_fast)) {
+    $static_fast['field_languages'] = &drupal_static(__FUNCTION__);
   }
-  $field_languages = &$drupal_static_fast['field_languages'];
+  $field_languages = &$static_fast['field_languages'];
   $field_name = $field['field_name'];
 
   if (!isset($field_languages[$entity_type][$field_name])) {
@@ -115,7 +116,7 @@ function field_available_languages($entity_type, $field) {
       $languages = field_content_languages();
       // Let other modules alter the available languages.
       $context = array('entity_type' => $entity_type, 'field' => $field);
-      drupal_alter('field_available_languages', $languages, $context);
+      alter('field_available_languages', $languages, $context);
       $field_languages[$entity_type][$field_name] = $languages;
     }
     else {
@@ -298,7 +299,7 @@ function field_language($entity_type, $entity, $field_name = NULL, $langcode = N
         'entity' => $entity,
         'language' => $langcode,
       );
-      drupal_alter('field_language', $display_language, $context);
+      alter('field_language', $display_language, $context);
     }
 
     $display_languages[$entity_type][$id][$langcode] = $display_language;
diff --git a/core/modules/field/modules/field_sql_storage/field_sql_storage.install b/core/modules/field/modules/field_sql_storage/field_sql_storage.install
index 4a3a00e..b1868a0 100644
--- a/core/modules/field/modules/field_sql_storage/field_sql_storage.install
+++ b/core/modules/field/modules/field_sql_storage/field_sql_storage.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -14,7 +15,7 @@ function field_sql_storage_schema() {
   // Dynamic (data) tables.
   if (db_table_exists('field_config')) {
     $fields = field_read_fields(array(), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
-    drupal_load('module', 'field_sql_storage');
+    load('module', 'field_sql_storage');
     foreach ($fields as $field) {
       if ($field['storage']['type'] == 'field_sql_storage') {
         $schema += _field_sql_storage_schema($field);
diff --git a/core/modules/field/modules/field_sql_storage/field_sql_storage.module b/core/modules/field/modules/field_sql_storage/field_sql_storage.module
index 92d244a..a531cbc 100644
--- a/core/modules/field/modules/field_sql_storage/field_sql_storage.module
+++ b/core/modules/field/modules/field_sql_storage/field_sql_storage.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -215,7 +217,7 @@ function field_sql_storage_field_storage_create_field($field) {
   foreach ($schema as $name => $table) {
     db_create_table($name, $table);
   }
-  drupal_get_schema(NULL, TRUE);
+  get_schema(NULL, TRUE);
 }
 
 /**
@@ -296,7 +298,7 @@ function field_sql_storage_field_storage_update_field($field, $prior_field, $has
       }
     }
   }
-  drupal_get_schema(NULL, TRUE);
+  get_schema(NULL, TRUE);
 }
 
 /**
@@ -317,7 +319,7 @@ function field_sql_storage_field_storage_delete_field($field) {
   $revision_new_table = _field_sql_storage_revision_tablename($field);
   db_rename_table($table, $new_table);
   db_rename_table($revision_table, $revision_new_table);
-  drupal_get_schema(NULL, TRUE);
+  get_schema(NULL, TRUE);
 }
 
 /**
@@ -493,11 +495,11 @@ function field_sql_storage_field_storage_purge($entity_type, $entity, $field, $i
  */
 function field_sql_storage_field_storage_query(EntityFieldQuery $query) {
   if ($query->age == FIELD_LOAD_CURRENT) {
-    $tablename_function = '_field_sql_storage_tablename';
+    $tablename_function = 'Drupal\_field_sql_storage_tablename';
     $id_key = 'entity_id';
   }
   else {
-    $tablename_function = '_field_sql_storage_revision_tablename';
+    $tablename_function = 'Drupal\_field_sql_storage_revision_tablename';
     $id_key = 'revision_id';
   }
   $table_aliases = array();
@@ -523,8 +525,8 @@ function field_sql_storage_field_storage_query(EntityFieldQuery $query) {
   }
 
   // Add field conditions. We need a fresh grouping cache.
-  drupal_static_reset('_field_sql_storage_query_field_conditions');
-  _field_sql_storage_query_field_conditions($query, $select_query, $query->fieldConditions, $table_aliases, '_field_sql_storage_columnname');
+  drupal_static_reset('Drupal\_field_sql_storage_query_field_conditions');
+  _field_sql_storage_query_field_conditions($query, $select_query, $query->fieldConditions, $table_aliases, 'Drupal\_field_sql_storage_columnname');
 
   // Add field meta conditions.
   _field_sql_storage_query_field_conditions($query, $select_query, $query->fieldMetaConditions, $table_aliases, function ($field_name, $column) { return $column; });
diff --git a/core/modules/field/modules/field_sql_storage/field_sql_storage.test b/core/modules/field/modules/field_sql_storage/field_sql_storage.test
index 773de3d..4369c11 100644
--- a/core/modules/field/modules/field_sql_storage/field_sql_storage.test
+++ b/core/modules/field/modules/field_sql_storage/field_sql_storage.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, PDO;
 
 /**
  * @file
@@ -11,7 +13,7 @@
 /**
  * Tests field storage.
  */
-class FieldSqlStorageTestCase extends DrupalWebTestCase {
+class FieldSqlStorageTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name'  => 'Field SQL storage tests',
@@ -417,7 +419,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
     $this->assertEqual($field['foreign keys']['format']['table'], 'filter_format', t('Foreign key table name preserved through CRUD'));
     $this->assertEqual($field['foreign keys']['format']['columns']['format'], 'format', t('Foreign key column name preserved through CRUD'));
     // Now grab the SQL schema and verify that too.
-    $schema = drupal_get_schema(_field_sql_storage_tablename($field));
+    $schema = get_schema(_field_sql_storage_tablename($field));
     $this->assertEqual(count($schema['foreign keys']), 1, t("There is 1 foreign key in the schema"));
     $foreign_key = reset($schema['foreign keys']);
     $filter_column = _field_sql_storage_columnname($field['field_name'], 'format');
diff --git a/core/modules/field/modules/list/list.install b/core/modules/field/modules/list/list.install
index c86a219..c6df80f 100644
--- a/core/modules/field/modules/list/list.install
+++ b/core/modules/field/modules/list/list.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/field/modules/list/list.module b/core/modules/field/modules/list/list.module
index 0d397a4..fd9382d 100644
--- a/core/modules/field/modules/list/list.module
+++ b/core/modules/field/modules/list/list.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -201,8 +203,8 @@ function list_allowed_values_setting_validate($element, &$form_state) {
 * Form element #value_callback: assembles the allowed values for 'boolean' fields.
 */
 function list_boolean_allowed_values_callback($element, $input, $form_state) {
-  $on = drupal_array_get_nested_value($form_state['input'], $element['#on_parents']);
-  $off = drupal_array_get_nested_value($form_state['input'], $element['#off_parents']);
+  $on = array_get_nested_value($form_state['input'], $element['#on_parents']);
+  $off = array_get_nested_value($form_state['input'], $element['#off_parents']);
   return array($off, $on);
 }
 
@@ -210,7 +212,7 @@ function list_boolean_allowed_values_callback($element, $input, $form_state) {
  * Implements hook_field_update_field().
  */
 function list_field_update_field($field, $prior_field, $has_data) {
-  drupal_static_reset('list_allowed_values');
+  drupal_static_reset('Drupal\list_allowed_values');
 }
 
 /**
@@ -230,8 +232,8 @@ function list_allowed_values($field) {
   $allowed_values = &drupal_static(__FUNCTION__, array());
 
   if (!isset($allowed_values[$field['id']])) {
-    $function = $field['settings']['allowed_values_function'];
-    if (!empty($function)) {
+    if (!empty($field['settings']['allowed_values_function'])) {
+      $function = 'Drupal\\' . $field['settings']['allowed_values_function'];
       $values = $function($field);
     }
     else {
diff --git a/core/modules/field/modules/list/tests/list.test b/core/modules/field/modules/list/tests/list.test
index 765901a..74cd3c9 100644
--- a/core/modules/field/modules/list/tests/list.test
+++ b/core/modules/field/modules/list/tests/list.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -50,7 +52,7 @@ class ListFieldTestCase extends FieldTestCase {
 
     // All three options appear.
     $entity = field_test_create_stub_entity();
-    $form = drupal_get_form('field_test_entity_form', $entity);
+    $form = get_form('field_test_entity_form', $entity);
     $this->assertTrue(!empty($form[$this->field_name][$langcode][1]), t('Option 1 exists'));
     $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), t('Option 2 exists'));
     $this->assertTrue(!empty($form[$this->field_name][$langcode][3]), t('Option 3 exists'));
@@ -76,7 +78,7 @@ class ListFieldTestCase extends FieldTestCase {
     $this->field['settings']['allowed_values'] = array(2 => 'Two');
     field_update_field($this->field);
     $entity = field_test_create_stub_entity();
-    $form = drupal_get_form('field_test_entity_form', $entity);
+    $form = get_form('field_test_entity_form', $entity);
     $this->assertTrue(empty($form[$this->field_name][$langcode][1]), t('Option 1 does not exist'));
     $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), t('Option 2 exists'));
     $this->assertTrue(empty($form[$this->field_name][$langcode][3]), t('Option 3 does not exist'));
@@ -84,7 +86,7 @@ class ListFieldTestCase extends FieldTestCase {
     // Completely new options appear.
     $this->field['settings']['allowed_values'] = array(10 => 'Update', 20 => 'Twenty');
     field_update_field($this->field);
-    $form = drupal_get_form('field_test_entity_form', $entity);
+    $form = get_form('field_test_entity_form', $entity);
     $this->assertTrue(empty($form[$this->field_name][$langcode][1]), t('Option 1 does not exist'));
     $this->assertTrue(empty($form[$this->field_name][$langcode][2]), t('Option 2 does not exist'));
     $this->assertTrue(empty($form[$this->field_name][$langcode][3]), t('Option 3 does not exist'));
@@ -106,7 +108,7 @@ class ListFieldTestCase extends FieldTestCase {
     );
     $this->instance = field_create_instance($this->instance);
     $entity = field_test_create_stub_entity();
-    $form = drupal_get_form('field_test_entity_form', $entity);
+    $form = get_form('field_test_entity_form', $entity);
     $this->assertTrue(!empty($form[$this->field_name][$langcode][1]), t('Option 1 exists'));
     $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), t('Option 2 exists'));
     $this->assertTrue(!empty($form[$this->field_name][$langcode][3]), t('Option 3 exists'));
diff --git a/core/modules/field/modules/list/tests/list_test.module b/core/modules/field/modules/list/tests/list_test.module
index 8d53404..276f8b6 100644
--- a/core/modules/field/modules/list/tests/list_test.module
+++ b/core/modules/field/modules/list/tests/list_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/field/modules/number/number.install b/core/modules/field/modules/number/number.install
index 02c7a30..1c9925c 100644
--- a/core/modules/field/modules/number/number.install
+++ b/core/modules/field/modules/number/number.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/field/modules/number/number.module b/core/modules/field/modules/number/number.module
index 87e2d3a..96572e5 100644
--- a/core/modules/field/modules/number/number.module
+++ b/core/modules/field/modules/number/number.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -60,7 +61,7 @@ function number_field_settings_form($field, $instance, $has_data) {
     $form['precision'] = array(
       '#type' => 'select',
       '#title' => t('Precision'),
-      '#options' => drupal_map_assoc(range(10, 32)),
+      '#options' => map_assoc(range(10, 32)),
       '#default_value' => $settings['precision'],
       '#description' => t('The total number of digits to store in the database, including those to the right of the decimal.'),
       '#disabled' => $has_data,
@@ -68,7 +69,7 @@ function number_field_settings_form($field, $instance, $has_data) {
     $form['scale'] = array(
       '#type' => 'select',
       '#title' => t('Scale'),
-      '#options' => drupal_map_assoc(range(0, 10)),
+      '#options' => map_assoc(range(0, 10)),
       '#default_value' => $settings['scale'],
       '#description' => t('The number of digits to the right of the decimal.'),
       '#disabled' => $has_data,
@@ -246,7 +247,7 @@ function number_field_formatter_settings_form($field, $instance, $view_mode, $fo
       $element['scale'] = array(
         '#type' => 'select',
         '#title' => t('Scale'),
-        '#options' => drupal_map_assoc(range(0, 10)),
+        '#options' => map_assoc(range(0, 10)),
         '#default_value' => $settings['scale'],
         '#description' => t('The number of digits to the right of the decimal.'),
       );
@@ -293,8 +294,8 @@ function number_field_formatter_view($entity_type, $entity, $field, $instance, $
       foreach ($items as $delta => $item) {
         $output = number_format($item['value'], $settings['scale'], $settings['decimal_separator'], $settings['thousand_separator']);
         if ($settings['prefix_suffix']) {
-          $prefixes = isset($instance['settings']['prefix']) ? array_map('field_filter_xss', explode('|', $instance['settings']['prefix'])) : array('');
-          $suffixes = isset($instance['settings']['suffix']) ? array_map('field_filter_xss', explode('|', $instance['settings']['suffix'])) : array('');
+          $prefixes = isset($instance['settings']['prefix']) ? array_map('Drupal\field_filter_xss', explode('|', $instance['settings']['prefix'])) : array('');
+          $suffixes = isset($instance['settings']['suffix']) ? array_map('Drupal\field_filter_xss', explode('|', $instance['settings']['suffix'])) : array('');
           $prefix = (count($prefixes) > 1) ? format_plural($item['value'], $prefixes[0], $prefixes[1]) : $prefixes[0];
           $suffix = (count($suffixes) > 1) ? format_plural($item['value'], $suffixes[0], $suffixes[1]) : $suffixes[0];
           $output = $prefix . $output . $suffix;
diff --git a/core/modules/field/modules/number/number.test b/core/modules/field/modules/number/number.test
index e96be42..b5a736c 100644
--- a/core/modules/field/modules/number/number.test
+++ b/core/modules/field/modules/number/number.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -8,7 +9,7 @@
 /**
  * Tests for number field types.
  */
-class NumberFieldTestCase extends DrupalWebTestCase {
+class NumberFieldTestCase extends WebTestCase {
   protected $field;
   protected $instance;
   protected $web_user;
diff --git a/core/modules/field/modules/options/options.api.php b/core/modules/field/modules/options/options.api.php
index d1ac0db..f4943a0 100644
--- a/core/modules/field/modules/options/options.api.php
+++ b/core/modules/field/modules/options/options.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/field/modules/options/options.module b/core/modules/field/modules/options/options.module
index d4d05ec..6a82ae6 100644
--- a/core/modules/field/modules/options/options.module
+++ b/core/modules/field/modules/options/options.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/field/modules/options/options.test b/core/modules/field/modules/options/options.test
index ea58f27..6d0cb95 100644
--- a/core/modules/field/modules/options/options.test
+++ b/core/modules/field/modules/options/options.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file 
diff --git a/core/modules/field/modules/text/text.install b/core/modules/field/modules/text/text.install
index 1b8d00b..47ef155 100644
--- a/core/modules/field/modules/text/text.install
+++ b/core/modules/field/modules/text/text.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/field/modules/text/text.module b/core/modules/field/modules/text/text.module
index d73814f..da3f3b5 100644
--- a/core/modules/field/modules/text/text.module
+++ b/core/modules/field/modules/text/text.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -523,7 +524,7 @@ function text_field_widget_form(&$form, &$form_state, $field, $instance, $langco
         '#rows' => $instance['widget']['settings']['summary_rows'],
         '#description' => t('Leave blank to use trimmed value of full text as the summary.'),
         '#attached' => array(
-          'js' => array(drupal_get_path('module', 'text') . '/text.js'),
+          'js' => array(get_path('module', 'text') . '/text.js'),
         ),
         '#attributes' => array('class' => array('text-summary')),
         '#prefix' => '<div class="text-summary-wrapper">',
diff --git a/core/modules/field/modules/text/text.test b/core/modules/field/modules/text/text.test
index 5936937..98586fb 100644
--- a/core/modules/field/modules/text/text.test
+++ b/core/modules/field/modules/text/text.test
@@ -1,11 +1,13 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
  * Tests for text.module.
  */
 
-class TextFieldTestCase extends DrupalWebTestCase {
+class TextFieldTestCase extends WebTestCase {
   protected $instance;
   protected $admin_user;
   protected $web_user;
@@ -237,7 +239,7 @@ class TextFieldTestCase extends DrupalWebTestCase {
   }
 }
 
-class TextSummaryTestCase extends DrupalWebTestCase {
+class TextSummaryTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Text summary',
@@ -405,7 +407,7 @@ class TextSummaryTestCase extends DrupalWebTestCase {
   }
 }
 
-class TextTranslationTestCase extends DrupalWebTestCase {
+class TextTranslationTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Text translation',
diff --git a/core/modules/field/tests/field.test b/core/modules/field/tests/field.test
index 0733bd0..1cc4457 100644
--- a/core/modules/field/tests/field.test
+++ b/core/modules/field/tests/field.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -8,7 +10,7 @@
 /**
  * Parent class for Field API tests.
  */
-class FieldTestCase extends DrupalWebTestCase {
+class FieldTestCase extends WebTestCase {
   var $default_storage = 'field_sql_storage';
 
   /**
@@ -16,7 +18,7 @@ class FieldTestCase extends DrupalWebTestCase {
    */
   function setUp() {
     // Since this is a base class for many test cases, support the same
-    // flexibility that DrupalWebTestCase::setUp() has for the modules to be
+    // flexibility that WebTestCase::setUp() has for the modules to be
     // passed in as either an array or a variable number of string arguments.
     $modules = func_get_args();
     if (isset($modules[0]) && is_array($modules[0])) {
@@ -74,7 +76,7 @@ class FieldTestCase extends DrupalWebTestCase {
 class FieldAttachTestCase extends FieldTestCase {
   function setUp() {
     // Since this is a base class for many test cases, support the same
-    // flexibility that DrupalWebTestCase::setUp() has for the modules to be
+    // flexibility that WebTestCase::setUp() has for the modules to be
     // passed in as either an array or a variable number of string arguments.
     $modules = func_get_args();
     if (isset($modules[0]) && is_array($modules[0])) {
@@ -1002,8 +1004,8 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase {
 
     $langcode = LANGUAGE_NONE;
     // Pretend the form has been built.
-    drupal_prepare_form('field_test_entity_form', $form, $form_state);
-    drupal_process_form('field_test_entity_form', $form, $form_state);
+    prepare_form('field_test_entity_form', $form, $form_state);
+    process_form('field_test_entity_form', $form, $form_state);
     $form_state['values'][$this->field_name][$langcode] = $values;
     field_attach_submit($entity_type, $entity, $form, $form_state);
 
@@ -2357,7 +2359,7 @@ class FieldCrudTestCase extends FieldTestCase {
     $this->assertTrue($field_definition <= $field, t('The field was properly read.'));
 
     module_disable($modules, FALSE);
-    drupal_flush_all_caches();
+    flush_all_caches();
 
     $fields = field_read_fields(array('field_name' => $field_name), array('include_inactive' => TRUE));
     $this->assertTrue(isset($fields[$field_name]) && $field_definition < $field, t('The field is properly read when explicitly fetching inactive fields.'));
@@ -2370,7 +2372,7 @@ class FieldCrudTestCase extends FieldTestCase {
 
       $module = array_shift($modules);
       module_enable(array($module), FALSE);
-      drupal_flush_all_caches();
+      flush_all_caches();
     }
 
     // Check that the field is active again after all modules have been
@@ -2643,7 +2645,7 @@ class FieldTranslationsTestCase extends FieldTestCase {
     field_create_instance($instance);
     $this->instance = field_read_instance('test_entity', $this->field_name, 'test_bundle');
 
-    require_once DRUPAL_ROOT . '/core/includes/locale.inc';
+    require_once ROOT . '/core/includes/locale.inc';
     for ($i = 0; $i < 3; ++$i) {
       $language = (object) array(
         'langcode' => 'l' . $i,
@@ -2879,7 +2881,7 @@ class FieldTranslationsTestCase extends FieldTestCase {
 
     // Test multiple-fields display languages for untranslatable entities.
     field_test_entity_info_translatable($entity_type, FALSE);
-    drupal_static_reset('field_language');
+    drupal_static_reset('Drupal\field_language');
     $requested_language = $enabled_languages[0];
     $display_language = field_language($entity_type, $entity, NULL, $requested_language);
     foreach ($instances as $instance) {
@@ -2889,7 +2891,7 @@ class FieldTranslationsTestCase extends FieldTestCase {
 
     // Test multiple-fields display languages for translatable entities.
     field_test_entity_info_translatable($entity_type, TRUE);
-    drupal_static_reset('field_language');
+    drupal_static_reset('Drupal\field_language');
     $display_language = field_language($entity_type, $entity, NULL, $requested_language);
 
     foreach ($instances as $instance) {
@@ -2902,14 +2904,14 @@ class FieldTranslationsTestCase extends FieldTestCase {
     }
 
     // Test single-field display language.
-    drupal_static_reset('field_language');
+    drupal_static_reset('Drupal\field_language');
     $langcode = field_language($entity_type, $entity, $this->field_name, $requested_language);
     $this->assertTrue(isset($entity->{$this->field_name}[$langcode]) && $langcode != $requested_language, t('The display language for the (single) field %field_name is %language.', array('%field_name' => $field_name, '%language' => $langcode)));
 
     // Test field_language() basic behavior without language fallback.
     variable_set('field_test_language_fallback', FALSE);
     $entity->{$this->field_name}[$requested_language] = mt_rand(1, 127);
-    drupal_static_reset('field_language');
+    drupal_static_reset('Drupal\field_language');
     $display_language = field_language($entity_type, $entity, $this->field_name, $requested_language);
     $this->assertEqual($display_language, $requested_language, t('Display language behave correctly when language fallback is disabled'));
   }
diff --git a/core/modules/field/tests/field_test.entity.inc b/core/modules/field/tests/field_test.entity.inc
index 52ed3fc..5a190bd 100644
--- a/core/modules/field/tests/field_test.entity.inc
+++ b/core/modules/field/tests/field_test.entity.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -138,7 +140,7 @@ function field_test_entity_info_alter(&$entity_info) {
  * Helper function to enable entity translations.
  */
 function field_test_entity_info_translatable($entity_type = NULL, $translatable = NULL) {
-  drupal_static_reset('field_has_translation_handler');
+  drupal_static_reset('Drupal\field_has_translation_handler');
   $stored_value = &drupal_static(__FUNCTION__, array());
   if (isset($entity_type)) {
     $stored_value[$entity_type] = $translatable;
@@ -287,17 +289,17 @@ function field_test_entity_save(&$entity) {
 
   $update_entity = TRUE;
   if ($entity->is_new) {
-    drupal_write_record('test_entity', $entity);
-    drupal_write_record('test_entity_revision', $entity);
+    write_record('test_entity', $entity);
+    write_record('test_entity_revision', $entity);
     $op = 'insert';
   }
   else {
-    drupal_write_record('test_entity', $entity, 'ftid');
+    write_record('test_entity', $entity, 'ftid');
     if (!empty($entity->revision)) {
-      drupal_write_record('test_entity_revision', $entity);
+      write_record('test_entity_revision', $entity);
     }
     else {
-      drupal_write_record('test_entity_revision', $entity, 'ftvid');
+      write_record('test_entity_revision', $entity, 'ftvid');
       $update_entity = FALSE;
     }
     $op = 'update';
@@ -310,7 +312,7 @@ function field_test_entity_save(&$entity) {
   }
 
   // Save fields.
-  $function = "field_attach_$op";
+  $function = 'Drupal\field_attach_' . $op;
   $function('test_entity', $entity);
 }
 
@@ -320,16 +322,16 @@ function field_test_entity_save(&$entity) {
 function field_test_entity_add($fttype) {
   $fttype = str_replace('-', '_', $fttype);
   $entity = (object)array('fttype' => $fttype);
-  drupal_set_title(t('Create test_entity @bundle', array('@bundle' => $fttype)), PASS_THROUGH);
-  return drupal_get_form('field_test_entity_form', $entity, TRUE);
+  set_title(t('Create test_entity @bundle', array('@bundle' => $fttype)), PASS_THROUGH);
+  return get_form('field_test_entity_form', $entity, TRUE);
 }
 
 /**
  * Menu callback: displays the 'Edit exiisting test_entity' form.
  */
 function field_test_entity_edit($entity) {
-  drupal_set_title(t('test_entity @ftid revision @ftvid', array('@ftid' => $entity->ftid, '@ftvid' => $entity->ftvid)), PASS_THROUGH);
-  return drupal_get_form('field_test_entity_form', $entity);
+  set_title(t('test_entity @ftid revision @ftvid', array('@ftid' => $entity->ftid, '@ftvid' => $entity->ftvid)), PASS_THROUGH);
+  return get_form('field_test_entity_form', $entity);
 }
 
 /**
@@ -390,14 +392,14 @@ function field_test_entity_form_submit($form, &$form_state) {
   field_test_entity_save($entity);
 
   $message = $insert ? t('test_entity @id has been created.', array('@id' => $entity->ftid)) : t('test_entity @id has been updated.', array('@id' => $entity->ftid));
-  drupal_set_message($message);
+  set_message($message);
 
   if ($entity->ftid) {
     $form_state['redirect'] = 'test-entity/manage/' . $entity->ftid . '/edit';
   }
   else {
     // Error on save.
-    drupal_set_message(t('The entity could not be saved.'), 'error');
+    set_message(t('The entity could not be saved.'), 'error');
     $form_state['rebuild'] = TRUE;
   }
 }
@@ -472,16 +474,16 @@ function field_test_entity_nested_form_submit($form, &$form_state) {
   field_attach_submit('test_entity', $entity_2, $form['entity_2'], $form_state);
   field_test_entity_save($entity_2);
 
-  drupal_set_message(t('test_entities @id_1 and @id_2 have been updated.', array('@id_1' => $entity_1->ftid, '@id_2' => $entity_2->ftid)));
+  set_message(t('test_entities @id_1 and @id_2 have been updated.', array('@id_1' => $entity_1->ftid, '@id_2' => $entity_2->ftid)));
 }
 
 /**
  * Controller class for the test_entity_bundle entity type.
  *
- * This extends the DrupalDefaultEntityController class, adding required
+ * This extends the DefaultEntityController class, adding required
  * special handling for bundles (since they are not stored in the database).
  */
-class TestEntityBundleController extends DrupalDefaultEntityController {
+class TestEntityBundleController extends DefaultEntityController {
 
   protected function attachLoad(&$entities, $revision_id = FALSE) {
     // Add bundle information.
diff --git a/core/modules/field/tests/field_test.field.inc b/core/modules/field/tests/field_test.field.inc
index cc76a99..34df5d0 100644
--- a/core/modules/field/tests/field_test.field.inc
+++ b/core/modules/field/tests/field_test.field.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
diff --git a/core/modules/field/tests/field_test.install b/core/modules/field/tests/field_test.install
index 5957561..238c28d 100644
--- a/core/modules/field/tests/field_test.install
+++ b/core/modules/field/tests/field_test.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/field/tests/field_test.module b/core/modules/field/tests/field_test.module
index 75823c6..f7b8aff 100644
--- a/core/modules/field/tests/field_test.module
+++ b/core/modules/field/tests/field_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -13,9 +14,9 @@
  * test helper functions
  */
 
-require_once DRUPAL_ROOT . '/core/modules/field/tests/field_test.entity.inc';
-require_once DRUPAL_ROOT . '/core/modules/field/tests/field_test.field.inc';
-require_once DRUPAL_ROOT . '/core/modules/field/tests/field_test.storage.inc';
+require_once ROOT . '/core/modules/field/tests/field_test.entity.inc';
+require_once ROOT . '/core/modules/field/tests/field_test.field.inc';
+require_once ROOT . '/core/modules/field/tests/field_test.storage.inc';
 
 /**
  * Implements hook_permission().
@@ -61,7 +62,7 @@ function field_test_menu() {
 
   $items['test-entity/nested/%field_test_entity_test/%field_test_entity_test'] = array(
     'title' => 'Nested entity form',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('field_test_entity_nested_form', 2, 3),
     'access arguments' => array('administer field_test content'),
     'type' => MENU_NORMAL_ITEM,
@@ -170,7 +171,8 @@ function field_test_memorize($key = NULL, $value = NULL) {
     return $return;
   }
   if (is_array($memorize)) {
-    $memorize[$key][] = $value;
+    // Remove the namespace from the function.
+    $memorize[substr($key, 7)][] = $value;
   }
 }
 
@@ -253,11 +255,11 @@ function field_test_field_widget_properties_user_alter(&$widget, $context) {
 function field_test_field_widget_form_alter(&$element, &$form_state, $context) {
   switch ($context['field']['field_name']) {
     case 'alter_test_text':
-      drupal_set_message('Field size: ' . $context['instance']['widget']['settings']['size']);
+      set_message('Field size: ' . $context['instance']['widget']['settings']['size']);
       break;
 
     case 'alter_test_options':
-      drupal_set_message('Widget type: ' . $context['instance']['widget']['type']);
+      set_message('Widget type: ' . $context['instance']['widget']['type']);
       break;
   }
 }
diff --git a/core/modules/field/tests/field_test.storage.inc b/core/modules/field/tests/field_test.storage.inc
index a26af17..995dc15 100644
--- a/core/modules/field/tests/field_test.storage.inc
+++ b/core/modules/field/tests/field_test.storage.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -254,7 +256,7 @@ function field_test_field_storage_query($field_id, $conditions, $count, &$cursor
   $field_data = $data[$field['id']];
   $sub_table = $load_current ? 'current' : 'revisions';
   // We need to sort records by entity type and entity id.
-  usort($field_data[$sub_table], '_field_test_field_storage_query_sort_helper');
+  usort($field_data[$sub_table], 'Drupal\_field_test_field_storage_query_sort_helper');
 
     // Initialize results array.
   $return = array();
diff --git a/core/modules/field/theme/field.tpl.php b/core/modules/field/theme/field.tpl.php
index 9e76e3b..b4dd865 100644
--- a/core/modules/field/theme/field.tpl.php
+++ b/core/modules/field/theme/field.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file field.tpl.php
diff --git a/core/modules/field_ui/field_ui.admin.inc b/core/modules/field_ui/field_ui.admin.inc
index 24a99e1..9b72bec 100644
--- a/core/modules/field_ui/field_ui.admin.inc
+++ b/core/modules/field_ui/field_ui.admin.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -71,7 +73,7 @@ function field_ui_inactive_message($entity_type, $bundle) {
       '%widget_module' => $instance['widget']['module'],
       ));
     }
-    drupal_set_message(t('Inactive fields are not shown unless their providing modules are enabled. The following fields are not enabled: !list', array('!list' => theme('item_list', array('items' => $list)))), 'error');
+    set_message(t('Inactive fields are not shown unless their providing modules are enabled. The following fields are not enabled: !list', array('!list' => theme('item_list', array('items' => $list)))), 'error');
   }
 }
 
@@ -86,8 +88,8 @@ function _field_ui_reduce_order($array, $a) {
     $array[] = $a['name'];
   }
   if (!empty($a['children'])) {
-    uasort($a['children'], 'drupal_sort_weight');
-    $array = array_merge($array, array_reduce($a['children'], '_field_ui_reduce_order'));
+    uasort($a['children'], 'Drupal\sort_weight');
+    $array = array_merge($array, array_reduce($a['children'], 'Drupal\_field_ui_reduce_order'));
   }
   return $array;
 }
@@ -145,7 +147,7 @@ function field_ui_table_pre_render($elements) {
   $trees = array_fill_keys(array_keys($regions), $tree);
 
   $parents = array();
-  $list = drupal_map_assoc(element_children($elements));
+  $list = map_assoc(element_children($elements));
 
   // Iterate on rows until we can build a known tree path for all of them.
   while ($list) {
@@ -159,7 +161,7 @@ function field_ui_table_pre_render($elements) {
         unset($list[$name]);
 
         // Determine the region for the row.
-        $function = $row['#region_callback'];
+        $function = 'Drupal\\' . $row['#region_callback'];
         $region_name = $function($row);
 
         // Add the element in the tree.
@@ -176,7 +178,7 @@ function field_ui_table_pre_render($elements) {
         }
 
         // Add row id and associate JS settings.
-        $id = drupal_html_class($name);
+        $id = html_class($name);
         $row['#attributes']['id'] = $id;
         if (isset($row['#js_settings'])) {
           $row['#js_settings'] += array(
@@ -191,7 +193,7 @@ function field_ui_table_pre_render($elements) {
   }
   // Determine rendering order from the tree structure.
   foreach ($regions as $region_name => $region) {
-    $elements['#regions'][$region_name]['rows_order'] = array_reduce($trees[$region_name], '_field_ui_reduce_order');
+    $elements['#regions'][$region_name]['rows_order'] = array_reduce($trees[$region_name], 'Drupal\_field_ui_reduce_order');
   }
 
   $elements['#attached']['js'][] = array(
@@ -233,7 +235,7 @@ function theme_field_ui_table($variables) {
 
   // Render rows, region by region.
   foreach ($elements['#regions'] as $region_name => $region) {
-    $region_name_class = drupal_html_class($region_name);
+    $region_name_class = html_class($region_name);
 
     // Add region rows.
     if (isset($region['title'])) {
@@ -636,8 +638,8 @@ function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle
   $form['actions'] = array('#type' => 'actions');
   $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
 
-  $form['#attached']['css'][] = drupal_get_path('module', 'field_ui') . '/field_ui.css';
-  $form['#attached']['js'][] = drupal_get_path('module', 'field_ui') . '/field_ui.js';
+  $form['#attached']['css'][] = get_path('module', 'field_ui') . '/field_ui.css';
+  $form['#attached']['js'][] = get_path('module', 'field_ui') . '/field_ui.js';
 
   // Add settings for the update selects behavior.
   $js_fields = array();
@@ -651,8 +653,8 @@ function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle
   );
 
   // Add tabledrag behavior.
-  $form['#attached']['drupal_add_tabledrag'][] = array('field-overview', 'order', 'sibling', 'field-weight');
-  $form['#attached']['drupal_add_tabledrag'][] = array('field-overview', 'match', 'parent', 'field-parent', 'field-parent', 'field-name');
+  $form['#attached']['add_tabledrag'][] = array('field-overview', 'order', 'sibling', 'field-weight');
+  $form['#attached']['add_tabledrag'][] = array('field-overview', 'match', 'parent', 'field-parent', 'field-parent', 'field-name');
 
   return $form;
 }
@@ -831,7 +833,7 @@ function field_ui_field_overview_form_submit($form, &$form_state) {
       $form_state['fields_added']['_add_new_field'] = $field['field_name'];
     }
     catch (Exception $e) {
-      drupal_set_message(t('There was a problem creating field %label: !message', array('%label' => $instance['label'], '!message' => $e->getMessage())), 'error');
+      set_message(t('There was a problem creating field %label: !message', array('%label' => $instance['label'], '!message' => $e->getMessage())), 'error');
     }
   }
 
@@ -840,7 +842,7 @@ function field_ui_field_overview_form_submit($form, &$form_state) {
     $values = $form_values['_add_existing_field'];
     $field = field_info_field($values['field_name']);
     if (!empty($field['locked'])) {
-      drupal_set_message(t('The field %label cannot be added because it is locked.', array('%label' => $values['label'])), 'error');
+      set_message(t('The field %label cannot be added because it is locked.', array('%label' => $values['label'])), 'error');
     }
     else {
       $instance = array(
@@ -861,19 +863,19 @@ function field_ui_field_overview_form_submit($form, &$form_state) {
         $form_state['fields_added']['_add_existing_field'] = $instance['field_name'];
       }
       catch (Exception $e) {
-        drupal_set_message(t('There was a problem creating field instance %label: @message.', array('%label' => $instance['label'], '@message' => $e->getMessage())), 'error');
+        set_message(t('There was a problem creating field instance %label: @message.', array('%label' => $instance['label'], '@message' => $e->getMessage())), 'error');
       }
     }
   }
 
   if ($destinations) {
-    $destination = drupal_get_destination();
+    $destination = get_destination();
     $destinations[] = $destination['destination'];
     unset($_GET['destination']);
     $form_state['redirect'] = field_ui_get_destinations($destinations);
   }
   else {
-    drupal_set_message(t('Your settings have been saved.'));
+    set_message(t('Your settings have been saved.'));
   }
 }
 
@@ -915,7 +917,7 @@ function field_ui_display_overview_form($form, &$form_state, $entity_type, $bund
   );
 
   if (empty($instances) && empty($extra_fields)) {
-    drupal_set_message(t('There are no fields yet added. You can add new fields on the <a href="@link">Manage fields</a> page.', array('@link' => url($admin_path . '/fields'))), 'warning');
+    set_message(t('There are no fields yet added. You can add new fields on the <a href="@link">Manage fields</a> page.', array('@link' => url($admin_path . '/fields'))), 'warning');
     return $form;
   }
 
@@ -1056,7 +1058,7 @@ function field_ui_display_overview_form($form, &$form_state, $entity_type, $bund
       $table[$name]['format']['settings_edit_form'] = array();
 
       $settings_form = array();
-      $function = $formatter['module'] . '_field_formatter_settings_form';
+      $function = 'Drupal\\' . $formatter['module'] . '_field_formatter_settings_form';
       if (function_exists($function)) {
         $settings_form = $function($field, $instance, $view_mode, $form, $form_state);
       }
@@ -1229,12 +1231,12 @@ function field_ui_display_overview_form($form, &$form_state, $entity_type, $bund
   $form['actions'] = array('#type' => 'actions');
   $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
 
-  $form['#attached']['js'][] = drupal_get_path('module', 'field_ui') . '/field_ui.js';
-  $form['#attached']['css'][] = drupal_get_path('module', 'field_ui') . '/field_ui.css';
+  $form['#attached']['js'][] = get_path('module', 'field_ui') . '/field_ui.js';
+  $form['#attached']['css'][] = get_path('module', 'field_ui') . '/field_ui.css';
 
   // Add tabledrag behavior.
-  $form['#attached']['drupal_add_tabledrag'][] = array('field-display-overview', 'order', 'sibling', 'field-weight');
-  $form['#attached']['drupal_add_tabledrag'][] = array('field-display-overview', 'match', 'parent', 'field-parent', 'field-parent', 'field-name');
+  $form['#attached']['add_tabledrag'][] = array('field-display-overview', 'order', 'sibling', 'field-weight');
+  $form['#attached']['add_tabledrag'][] = array('field-display-overview', 'match', 'parent', 'field-parent', 'field-parent', 'field-name');
 
   return $form;
 }
@@ -1381,7 +1383,7 @@ function field_ui_display_overview_form_submit($form, &$form_state) {
       if (!empty($value) && empty($view_mode_settings[$view_mode_name]['custom_settings'])) {
         $view_mode_label = $entity_info['view modes'][$view_mode_name]['label'];
         $path = _field_ui_bundle_admin_path($entity_type, $bundle) . "/display/$view_mode_name";
-        drupal_set_message(t('The %view_mode mode now uses custom display settings. You might want to <a href="@url">configure them</a>.', array('%view_mode' => $view_mode_label, '@url' => url($path))));
+        set_message(t('The %view_mode mode now uses custom display settings. You might want to <a href="@url">configure them</a>.', array('%view_mode' => $view_mode_label, '@url' => url($path))));
         // Initialize the newly customized view mode with the display settings
         // from the default view mode.
         _field_ui_add_default_view_mode_settings($entity_type, $bundle, $view_mode_name, $bundle_settings);
@@ -1393,7 +1395,7 @@ function field_ui_display_overview_form_submit($form, &$form_state) {
   // Save updated bundle settings.
   field_bundle_settings($entity_type, $bundle, $bundle_settings);
 
-  drupal_set_message(t('Your settings have been saved.'));
+  set_message(t('Your settings have been saved.'));
 }
 
 /**
@@ -1581,7 +1583,7 @@ function field_ui_field_settings_form($form, &$form_state, $instance) {
   $entity_type = $instance['entity_type'];
   $field = field_info_field($instance['field_name']);
 
-  drupal_set_title($instance['label']);
+  set_title($instance['label']);
 
   $description = '<p>' . t('These settings apply to the %field field everywhere it is used. These settings impact the way that data is stored in the database and cannot be changed once data has been created.', array('%field' => $instance['label'])) . '</p>';
 
@@ -1646,11 +1648,11 @@ function field_ui_field_settings_form_submit($form, &$form_state) {
 
   try {
     field_update_field($field);
-    drupal_set_message(t('Updated field %label field settings.', array('%label' => $instance['label'])));
+    set_message(t('Updated field %label field settings.', array('%label' => $instance['label'])));
     $form_state['redirect'] = field_ui_next_destination($entity_type, $bundle);
   }
   catch (Exception $e) {
-    drupal_set_message(t('Attempt to update field %label failed: %message.', array('%label' => $instance['label'], '%message' => $e->getMessage())), 'error');
+    set_message(t('Attempt to update field %label failed: %message.', array('%label' => $instance['label'], '%message' => $e->getMessage())), 'error');
   }
 }
 
@@ -1666,7 +1668,7 @@ function field_ui_field_settings_form_submit($form, &$form_state) {
  * @ingroup forms
  */
 function field_ui_widget_type_form($form, &$form_state, $instance) {
-  drupal_set_title($instance['label']);
+  set_title($instance['label']);
 
   $bundle = $instance['bundle'];
   $entity_type = $instance['entity_type'];
@@ -1727,10 +1729,10 @@ function field_ui_widget_type_form_submit($form, &$form_state) {
 
   try {
     field_update_instance($instance);
-    drupal_set_message(t('Changed the widget for field %label.', array('%label' => $instance['label'])));
+    set_message(t('Changed the widget for field %label.', array('%label' => $instance['label'])));
   }
   catch (Exception $e) {
-    drupal_set_message(t('There was a problem changing the widget for field %label.', array('%label' => $instance['label'])), 'error');
+    set_message(t('There was a problem changing the widget for field %label.', array('%label' => $instance['label'])), 'error');
   }
 
   $form_state['redirect'] = field_ui_next_destination($entity_type, $bundle);
@@ -1793,10 +1795,10 @@ function field_ui_field_delete_form_submit($form, &$form_state) {
 
   if (!empty($bundle) && $field && !$field['locked'] && $form_values['confirm']) {
     field_delete_instance($instance);
-    drupal_set_message(t('The field %field has been deleted from the %type content type.', array('%field' => $instance['label'], '%type' => $bundle_label)));
+    set_message(t('The field %field has been deleted from the %type content type.', array('%field' => $instance['label'], '%type' => $bundle_label)));
   }
   else {
-    drupal_set_message(t('There was a problem removing the %field from the %type content type.', array('%field' => $instance['label'], '%type' => $bundle_label)), 'error');
+    set_message(t('There was a problem removing the %field from the %type content type.', array('%field' => $instance['label'], '%type' => $bundle_label)), 'error');
   }
 
   $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
@@ -1831,7 +1833,7 @@ function field_ui_field_edit_form($form, &$form_state, $instance) {
   $entity_type = $instance['entity_type'];
   $field = field_info_field($instance['field_name']);
 
-  drupal_set_title($instance['label']);
+  set_title($instance['label']);
 
   $form['#field'] = $field;
   $form['#instance'] = $instance;
@@ -1962,7 +1964,7 @@ function field_ui_field_edit_form($form, &$form_state, $instance) {
   $form['field']['cardinality'] = array(
     '#type' => 'select',
     '#title' => t('Number of values'),
-    '#options' => array(FIELD_CARDINALITY_UNLIMITED => t('Unlimited')) + drupal_map_assoc(range(1, 10)),
+    '#options' => array(FIELD_CARDINALITY_UNLIMITED => t('Unlimited')) + map_assoc(range(1, 10)),
     '#default_value' => $field['cardinality'],
     '#description' => $description,
   );
@@ -1994,7 +1996,7 @@ function field_ui_field_edit_form($form, &$form_state, $instance) {
 function field_ui_field_edit_form_delete_submit($form, &$form_state) {
   $destination = array();
   if (isset($_GET['destination'])) {
-    $destination = drupal_get_destination();
+    $destination = get_destination();
     unset($_GET['destination']);
   }
   $instance = $form['#instance'];
@@ -2083,7 +2085,7 @@ function field_ui_field_edit_form_validate($form, &$form_state) {
 
     // Validate the value and report errors.
     $errors = array();
-    $function = $field['module'] . '_field_validate';
+    $function = 'Drupal\\' . $field['module'] . '_field_validate';
     if (function_exists($function)) {
       $function(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $errors);
     }
@@ -2113,7 +2115,7 @@ function field_ui_field_edit_form_submit($form, &$form_state) {
     field_update_field($field);
   }
   catch (Exception $e) {
-    drupal_set_message(t('Attempt to update field %label failed: %message.', array('%label' => $instance['label'], '%message' => $e->getMessage())), 'error');
+    set_message(t('Attempt to update field %label failed: %message.', array('%label' => $instance['label'], '%message' => $e->getMessage())), 'error');
     return;
   }
 
@@ -2134,7 +2136,7 @@ function field_ui_field_edit_form_submit($form, &$form_state) {
   $instance = array_merge($instance_source, $instance);
   field_update_instance($instance);
 
-  drupal_set_message(t('Saved %label configuration.', array('%label' => $instance['label'])));
+  set_message(t('Saved %label configuration.', array('%label' => $instance['label'])));
 
   $form_state['redirect'] = field_ui_next_destination($instance['entity_type'], $instance['bundle']);
 }
diff --git a/core/modules/field_ui/field_ui.api.php b/core/modules/field_ui/field_ui.api.php
index f903e12..849ce37 100644
--- a/core/modules/field_ui/field_ui.api.php
+++ b/core/modules/field_ui/field_ui.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module
index ab807dc..b3e1bf8 100644
--- a/core/modules/field_ui/field_ui.module
+++ b/core/modules/field_ui/field_ui.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 /**
  * @file
  * Allows administrators to attach custom fields to fieldable types.
@@ -95,7 +96,7 @@ function field_ui_menu() {
           $field_position = count(explode('/', $path)) + 1;
 
           // Extract access information, providing defaults.
-          $access = array_intersect_key($bundle_info['admin'], drupal_map_assoc(array('access callback', 'access arguments')));
+          $access = array_intersect_key($bundle_info['admin'], map_assoc(array('access callback', 'access arguments')));
           $access += array(
             'access callback' => 'user_access',
             'access arguments' => array('administer site configuration'),
@@ -103,7 +104,7 @@ function field_ui_menu() {
 
           $items["$path/fields"] = array(
             'title' => 'Manage fields',
-            'page callback' => 'drupal_get_form',
+            'page callback' => 'get_form',
             'page arguments' => array('field_ui_field_overview_form', $entity_type, $bundle_arg),
             'type' => MENU_LOCAL_TASK,
             'weight' => 1,
@@ -113,14 +114,14 @@ function field_ui_menu() {
             'load arguments' => array($entity_type, $bundle_arg, $bundle_pos, '%map'),
             'title callback' => 'field_ui_menu_title',
             'title arguments' => array($field_position),
-            'page callback' => 'drupal_get_form',
+            'page callback' => 'get_form',
             'page arguments' => array('field_ui_field_edit_form', $field_position),
             'file' => 'field_ui.admin.inc',
           ) + $access;
           $items["$path/fields/%field_ui_menu/edit"] = array(
             'load arguments' => array($entity_type, $bundle_arg, $bundle_pos, '%map'),
             'title' => 'Edit',
-            'page callback' => 'drupal_get_form',
+            'page callback' => 'get_form',
             'page arguments' => array('field_ui_field_edit_form', $field_position),
             'type' => MENU_DEFAULT_LOCAL_TASK,
             'file' => 'field_ui.admin.inc',
@@ -128,7 +129,7 @@ function field_ui_menu() {
           $items["$path/fields/%field_ui_menu/field-settings"] = array(
             'load arguments' => array($entity_type, $bundle_arg, $bundle_pos, '%map'),
             'title' => 'Field settings',
-            'page callback' => 'drupal_get_form',
+            'page callback' => 'get_form',
             'page arguments' => array('field_ui_field_settings_form', $field_position),
             'type' => MENU_LOCAL_TASK,
             'file' => 'field_ui.admin.inc',
@@ -136,7 +137,7 @@ function field_ui_menu() {
           $items["$path/fields/%field_ui_menu/widget-type"] = array(
             'load arguments' => array($entity_type, $bundle_arg, $bundle_pos, '%map'),
             'title' => 'Widget type',
-            'page callback' => 'drupal_get_form',
+            'page callback' => 'get_form',
             'page arguments' => array('field_ui_widget_type_form', $field_position),
             'type' => MENU_LOCAL_TASK,
             'file' => 'field_ui.admin.inc',
@@ -144,7 +145,7 @@ function field_ui_menu() {
           $items["$path/fields/%field_ui_menu/delete"] = array(
             'load arguments' => array($entity_type, $bundle_arg, $bundle_pos, '%map'),
             'title' => 'Delete',
-            'page callback' => 'drupal_get_form',
+            'page callback' => 'get_form',
             'page arguments' => array('field_ui_field_delete_form', $field_position),
             'type' => MENU_VISIBLE_IN_BREADCRUMB,
             'weight' => 10,
@@ -154,7 +155,7 @@ function field_ui_menu() {
           // 'Manage display' tab.
           $items["$path/display"] = array(
             'title' => 'Manage display',
-            'page callback' => 'drupal_get_form',
+            'page callback' => 'get_form',
             'page arguments' => array('field_ui_display_overview_form', $entity_type, $bundle_arg, 'default'),
             'type' => MENU_LOCAL_TASK,
             'weight' => 2,
@@ -280,7 +281,7 @@ function _field_ui_view_mode_menu_access($entity_type, $bundle, $view_mode, $acc
         return (count($args) == 1) ? user_access($args[0]) : user_access($args[0], $args[1]);
       }
       else {
-        return call_user_func_array($access_callback, $args);
+        return call_user_func_array('Drupal\\' . $access_callback, $args);
       }
     }
   }
diff --git a/core/modules/field_ui/field_ui.test b/core/modules/field_ui/field_ui.test
index c2e3a98..01d51dc 100644
--- a/core/modules/field_ui/field_ui.test
+++ b/core/modules/field_ui/field_ui.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -8,11 +9,11 @@
 /**
  * Provides common functionality for the Field UI test classes.
  */
-class FieldUITestCase extends DrupalWebTestCase {
+class FieldUITestCase extends WebTestCase {
 
   function setUp() {
     // Since this is a base class for many test cases, support the same
-    // flexibility that DrupalWebTestCase::setUp() has for the modules to be
+    // flexibility that WebTestCase::setUp() has for the modules to be
     // passed in as either an array or a variable number of string arguments.
     $modules = func_get_args();
     if (isset($modules[0]) && is_array($modules[0])) {
@@ -665,7 +666,7 @@ class FieldUIManageDisplayTestCase extends FieldUITestCase {
     $output = drupal_render($element);
     $this->verbose(t('Rendered node - view mode: @view_mode', array('@view_mode' => $view_mode)) . '<hr />'. $output);
 
-    // Assign content so that DrupalWebTestCase functions can be used.
+    // Assign content so that WebTestCase functions can be used.
     $this->drupalSetContent($output);
     $method = ($not_exists ? 'assertNoText' : 'assertText');
     $return = $this->{$method}((string) $text, $message);
@@ -680,7 +681,7 @@ class FieldUIManageDisplayTestCase extends FieldUITestCase {
 /**
  * Tests custom widget hooks and callbacks on the field administration pages.
  */
-class FieldUIAlterTestCase extends DrupalWebTestCase {
+class FieldUIAlterTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Widget customization',
diff --git a/core/modules/file/file.api.php b/core/modules/file/file.api.php
index 7f20d83..d61a56e 100644
--- a/core/modules/file/file.api.php
+++ b/core/modules/file/file.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc
index a46ed1a..d01b5e3 100644
--- a/core/modules/file/file.field.inc
+++ b/core/modules/file/file.field.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -37,7 +38,7 @@ function file_field_settings_form($field, $instance, $has_data) {
   $defaults = field_info_field_settings($field['type']);
   $settings = array_merge($defaults, $field['settings']);
 
-  $form['#attached']['js'][] = drupal_get_path('module', 'file') . '/file.js';
+  $form['#attached']['js'][] = get_path('module', 'file') . '/file.js';
 
   $form['display_field'] = array(
     '#type' => 'checkbox',
@@ -659,7 +660,7 @@ function file_field_widget_process($element, &$form_state, $form) {
   if ($field['cardinality'] != 1) {
     $parents = array_slice($element['#array_parents'], 0, -1);
     $new_path = 'file/ajax/' . implode('/', $parents) . '/' . $form['form_build_id']['#value'];
-    $field_element = drupal_array_get_nested_value($form, $parents);
+    $field_element = array_get_nested_value($form, $parents);
     $new_wrapper = $field_element['#id'] . '-ajax-wrapper';
     foreach (element_children($element) as $key) {
       if (isset($element[$key]['#ajax'])) {
@@ -763,17 +764,17 @@ function file_field_widget_submit($form, &$form_state) {
   // have #default_value set appropriately for the current state of the field,
   // so nothing is lost in doing this.
   $parents = array_slice($form_state['triggering_element']['#parents'], 0, -2);
-  drupal_array_set_nested_value($form_state['input'], $parents, NULL);
+  array_set_nested_value($form_state['input'], $parents, NULL);
 
   $button = $form_state['triggering_element'];
 
   // Go one level up in the form, to the widgets container.
-  $element = drupal_array_get_nested_value($form, array_slice($button['#array_parents'], 0, -1));
+  $element = array_get_nested_value($form, array_slice($button['#array_parents'], 0, -1));
   $field_name = $element['#field_name'];
   $langcode = $element['#language'];
   $parents = $element['#field_parents'];
 
-  $submitted_values = drupal_array_get_nested_value($form_state['values'], array_slice($button['#array_parents'], 0, -2));
+  $submitted_values = array_get_nested_value($form_state['values'], array_slice($button['#array_parents'], 0, -2));
   foreach ($submitted_values as $delta => $submitted_value) {
     if (!$submitted_value['fid']) {
       unset($submitted_values[$delta]);
@@ -784,7 +785,7 @@ function file_field_widget_submit($form, &$form_state) {
   $submitted_values = array_values($submitted_values);
 
   // Update form_state values.
-  drupal_array_set_nested_value($form_state['values'], array_slice($button['#array_parents'], 0, -2), $submitted_values);
+  array_set_nested_value($form_state['values'], array_slice($button['#array_parents'], 0, -2), $submitted_values);
 
   // Update items.
   $field_state = field_form_get_state($parents, $field_name, $langcode, $form_state);
@@ -811,7 +812,7 @@ function theme_file_widget($variables) {
     // Add the file size after the file name.
     $element['filename']['#markup'] .= ' <span class="file-size">(' . format_size($element['#file']->filesize) . ')</span> ';
   }
-  $output .= drupal_render_children($element);
+  $output .= render_children($element);
   $output .= '</div>';
 
   return $output;
@@ -851,7 +852,7 @@ function theme_file_widget_multiple($variables) {
   foreach (element_children($element) as $key) {
     $widgets[] = &$element[$key];
   }
-  usort($widgets, '_field_sort_items_value_helper');
+  usort($widgets, 'Drupal\_field_sort_items_value_helper');
 
   $rows = array();
   foreach ($widgets as $key => &$widget) {
@@ -914,11 +915,11 @@ function theme_file_widget_multiple($variables) {
     );
   }
 
-  drupal_add_tabledrag($table_id, 'order', 'sibling', $weight_class);
+  add_tabledrag($table_id, 'order', 'sibling', $weight_class);
 
   $output = '';
   $output = empty($rows) ? '' : theme('table', array('header' => $headers, 'rows' => $rows, 'attributes' => array('id' => $table_id)));
-  $output .= drupal_render_children($element);
+  $output .= render_children($element);
   return $output;
 }
 
diff --git a/core/modules/file/file.install b/core/modules/file/file.install
index 47ee4fd..97d4791 100644
--- a/core/modules/file/file.install
+++ b/core/modules/file/file.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index c951807..dae9933 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -6,7 +7,7 @@
  */
 
 // Load all Field module hooks for File.
-require_once DRUPAL_ROOT . '/core/modules/file/file.field.inc';
+require_once ROOT . '/core/modules/file/file.field.inc';
 
 /**
  * Implements hook_help().
@@ -59,7 +60,7 @@ function file_menu() {
  * The managed file element may be used anywhere in Drupal.
  */
 function file_element_info() {
-  $file_path = drupal_get_path('module', 'file');
+  $file_path = get_path('module', 'file');
   $types['managed_file'] = array(
     '#input' => TRUE,
     '#process' => array('file_managed_file_process'),
@@ -193,7 +194,7 @@ function file_file_download($uri, $field_type = 'file') {
           $grants = array_merge($grants, array($module => module_invoke($module, 'file_download_access', $field, $entity_type, $entity)));
         }
         // Allow other modules to alter the returned grants/denies.
-        drupal_alter('file_download_access', $grants, $field, $entity_type, $entity);
+        alter('file_download_access', $grants, $field, $entity_type, $entity);
 
         if (in_array(TRUE, $grants)) {
           // If TRUE is returned, access is granted and no further checks are
@@ -240,7 +241,7 @@ function file_ajax_upload() {
 
   if (empty($_POST['form_build_id']) || $form_build_id != $_POST['form_build_id']) {
     // Invalid request.
-    drupal_set_message(t('An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (@size) that this server supports.', array('@size' => format_size(file_upload_max_size()))), 'error');
+    set_message(t('An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (@size) that this server supports.', array('@size' => format_size(file_upload_max_size()))), 'error');
     $commands = array();
     $commands[] = ajax_command_replace(NULL, theme('status_messages'));
     return array('#type' => 'ajax', '#commands' => $commands);
@@ -250,7 +251,7 @@ function file_ajax_upload() {
 
   if (!$form) {
     // Invalid form_build_id.
-    drupal_set_message(t('An unrecoverable error occurred. Use of this form has expired. Try reloading the page and submitting again.'), 'error');
+    set_message(t('An unrecoverable error occurred. Use of this form has expired. Try reloading the page and submitting again.'), 'error');
     $commands = array();
     $commands[] = ajax_command_replace(NULL, theme('status_messages'));
     return array('#type' => 'ajax', '#commands' => $commands);
@@ -264,7 +265,7 @@ function file_ajax_upload() {
   $current_file_count = isset($current_element['#file_upload_delta']) ? $current_element['#file_upload_delta'] : 0;
 
   // Process user input. $form and $form_state are modified in the process.
-  drupal_process_form($form['#form_id'], $form, $form_state);
+  process_form($form['#form_id'], $form, $form_state);
 
   // Retrieve the element to be rendered.
   foreach ($form_parents as $parent) {
@@ -281,7 +282,7 @@ function file_ajax_upload() {
   }
 
   $output = theme('status_messages') . drupal_render($form);
-  $js = drupal_add_js();
+  $js = add_js();
   $settings = call_user_func_array('array_merge_recursive', $js['settings']['data']);
 
   $commands = array();
@@ -319,7 +320,7 @@ function file_ajax_progress($key) {
     }
   }
 
-  drupal_json_output($progress);
+  json_output($progress);
 }
 
 /**
@@ -592,7 +593,7 @@ function file_managed_file_submit($form, &$form_state) {
   // and set $element to the managed_file element that contains that button.
   $parents = $form_state['triggering_element']['#array_parents'];
   $button_key = array_pop($parents);
-  $element = drupal_array_get_nested_value($form, $parents);
+  $element = array_get_nested_value($form, $parents);
 
   // No action is needed here for the upload button, because all file uploads on
   // the form are processed by file_managed_file_value() regardless of which
@@ -613,7 +614,7 @@ function file_managed_file_submit($form, &$form_state) {
     // has correct information during the rebuild.
     $values_element = $element['#extended'] ? $element['fid'] : $element;
     form_set_value($values_element, NULL, $form_state);
-    drupal_array_set_nested_value($form_state['input'], $values_element['#parents'], NULL);
+    array_set_nested_value($form_state['input'], $values_element['#parents'], NULL);
   }
 
   // Set the form to rebuild so that $form is correctly updated in response to
@@ -680,8 +681,8 @@ function theme_file_managed_file($variables) {
 
   // This wrapper is required to apply JS behaviors and CSS styling.
   $output = '';
-  $output .= '<div' . drupal_attributes($attributes) . '>';
-  $output .= drupal_render_children($element);
+  $output .= '<div' . attributes($attributes) . '>';
+  $output .= render_children($element);
   $output .= '</div>';
   return $output;
 }
@@ -813,7 +814,7 @@ function file_icon_url($file, $icon_directory = NULL) {
 function file_icon_path($file, $icon_directory = NULL) {
   // Use the default set of icons if none specified.
   if (!isset($icon_directory)) {
-    $icon_directory = variable_get('file_icon_directory', drupal_get_path('module', 'file') . '/icons');
+    $icon_directory = variable_get('file_icon_directory', get_path('module', 'file') . '/icons');
   }
 
   // If there's an icon matching the exact mimetype, go for it.
diff --git a/core/modules/file/tests/file.test b/core/modules/file/tests/file.test
index 8dad362..7bad211 100644
--- a/core/modules/file/tests/file.test
+++ b/core/modules/file/tests/file.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -8,12 +9,12 @@
 /**
  * Provides methods specifically for testing File module's field handling.
  */
-class FileFieldTestCase extends DrupalWebTestCase {
+class FileFieldTestCase extends WebTestCase {
   protected $admin_user;
 
   function setUp() {
     // Since this is a base class for many test cases, support the same
-    // flexibility that DrupalWebTestCase::setUp() has for the modules to be
+    // flexibility that WebTestCase::setUp() has for the modules to be
     // passed in as either an array or a variable number of string arguments.
     $modules = func_get_args();
     if (isset($modules[0]) && is_array($modules[0])) {
diff --git a/core/modules/file/tests/file_module_test.module b/core/modules/file/tests/file_module_test.module
index 48ba87b..8f913fc 100644
--- a/core/modules/file/tests/file_module_test.module
+++ b/core/modules/file/tests/file_module_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -13,7 +14,7 @@ function file_module_test_menu() {
 
   $items['file/test'] = array(
     'title' => 'Managed file test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('file_module_test_form'),
     'access arguments' => array('access content'),
   );
@@ -67,7 +68,7 @@ function file_module_test_form_submit($form, &$form_state) {
   else {
     $fid = $form['nested']['file']['#extended'] ? $form_state['values']['file']['fid'] : $form_state['values']['file'];
   }
-  drupal_set_message(t('The file id is %fid.', array('%fid' => $fid)));
+  set_message(t('The file id is %fid.', array('%fid' => $fid)));
 }
 
 /**
diff --git a/core/modules/filter/filter.admin.inc b/core/modules/filter/filter.admin.inc
index b4a7008..b5043e3 100644
--- a/core/modules/filter/filter.admin.inc
+++ b/core/modules/filter/filter.admin.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -22,12 +24,12 @@ function filter_admin_overview($form) {
     // to all roles and cannot be disabled via the admin interface.
     $form['formats'][$id]['#is_fallback'] = ($id == $fallback_format);
     if ($form['formats'][$id]['#is_fallback']) {
-      $form['formats'][$id]['name'] = array('#markup' => drupal_placeholder($format->name));
-      $roles_markup = drupal_placeholder(t('All roles may use this format'));
+      $form['formats'][$id]['name'] = array('#markup' => placeholder($format->name));
+      $roles_markup = placeholder(t('All roles may use this format'));
     }
     else {
       $form['formats'][$id]['name'] = array('#markup' => check_plain($format->name));
-      $roles = array_map('check_plain', filter_get_roles_by_format($format));
+      $roles = array_map('Drupal\check_plain', filter_get_roles_by_format($format));
       $roles_markup = $roles ? implode(', ', $roles) : t('No roles may use this format');
     }
     $form['formats'][$id]['roles'] = array('#markup' => $roles_markup);
@@ -56,7 +58,7 @@ function filter_admin_overview_submit($form, &$form_state) {
     }
   }
   filter_formats_reset();
-  drupal_set_message(t('The text format ordering has been saved.'));
+  set_message(t('The text format ordering has been saved.'));
 }
 
 /**
@@ -87,9 +89,9 @@ function theme_filter_admin_overview($variables) {
   }
   $header = array(t('Name'), t('Roles'), t('Weight'), array('data' => t('Operations'), 'colspan' => 2));
   $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'text-format-order')));
-  $output .= drupal_render_children($form);
+  $output .= render_children($form);
 
-  drupal_add_tabledrag('text-format-order', 'order', 'sibling', 'text-format-order-weight');
+  add_tabledrag('text-format-order', 'order', 'sibling', 'text-format-order-weight');
 
   return $output;
 }
@@ -99,13 +101,13 @@ function theme_filter_admin_overview($variables) {
  */
 function filter_admin_format_page($format = NULL) {
   if (!isset($format->name)) {
-    drupal_set_title(t('Add text format'));
+    set_title(t('Add text format'));
     $format = (object) array(
       'format' => NULL,
       'name' => '',
     );
   }
-  return drupal_get_form('filter_admin_format_form', $format);
+  return get_form('filter_admin_format_form', $format);
 }
 
 /**
@@ -120,8 +122,8 @@ function filter_admin_format_form($form, &$form_state, $format) {
 
   $form['#format'] = $format;
   $form['#tree'] = TRUE;
-  $form['#attached']['js'][] = drupal_get_path('module', 'filter') . '/filter.admin.js';
-  $form['#attached']['css'][] = drupal_get_path('module', 'filter') . '/filter.css';
+  $form['#attached']['js'][] = get_path('module', 'filter') . '/filter.admin.js';
+  $form['#attached']['css'][] = get_path('module', 'filter') . '/filter.css';
 
   $form['name'] = array(
     '#type' => 'textfield',
@@ -144,7 +146,7 @@ function filter_admin_format_form($form, &$form_state, $format) {
   $form['roles'] = array(
     '#type' => 'checkboxes',
     '#title' => t('Roles'),
-    '#options' => array_map('check_plain', user_roles()),
+    '#options' => array_map('Drupal\check_plain', user_roles()),
     '#disabled' => $is_fallback,
   );
   if ($is_fallback) {
@@ -231,7 +233,7 @@ function filter_admin_format_form($form, &$form_state, $format) {
 
   foreach ($filter_info as $name => $filter) {
     if (isset($filter['settings callback'])) {
-      $function = $filter['settings callback'];
+      $function = 'Drupal\\' . $filter['settings callback'];
       // Pass along stored filter settings and default settings, but also the
       // format object and all filters to allow for complex implementations.
       $defaults = (isset($filter['default settings']) ? $filter['default settings'] : array());
@@ -279,9 +281,9 @@ function theme_filter_admin_format_filter_order($variables) {
       'class' => array('draggable'),
     );
   }
-  $output = drupal_render_children($element);
+  $output = render_children($element);
   $output .= theme('table', array('rows' => $rows, 'attributes' => array('id' => 'filter-order')));
-  drupal_add_tabledrag('filter-order', 'order', 'sibling', 'filter-order-weight', NULL, NULL, TRUE);
+  add_tabledrag('filter-order', 'order', 'sibling', 'filter-order-weight', NULL, NULL, TRUE);
 
   return $output;
 }
@@ -326,11 +328,11 @@ function filter_admin_format_form_submit($form, &$form_state) {
 
   switch ($status) {
     case SAVED_NEW:
-      drupal_set_message(t('Added text format %format.', array('%format' => $format->name)));
+      set_message(t('Added text format %format.', array('%format' => $format->name)));
       break;
 
     case SAVED_UPDATED:
-      drupal_set_message(t('The text format %format has been updated.', array('%format' => $format->name)));
+      set_message(t('The text format %format has been updated.', array('%format' => $format->name)));
       break;
   }
 }
@@ -358,7 +360,7 @@ function filter_admin_disable($form, &$form_state, $format) {
 function filter_admin_disable_submit($form, &$form_state) {
   $format = $form['#format'];
   filter_format_disable($format);
-  drupal_set_message(t('Disabled text format %format.', array('%format' => $format->name)));
+  set_message(t('Disabled text format %format.', array('%format' => $format->name)));
 
   $form_state['redirect'] = 'admin/config/content/formats';
 }
diff --git a/core/modules/filter/filter.api.php b/core/modules/filter/filter.api.php
index 6675e4a..f8bfe06 100644
--- a/core/modules/filter/filter.api.php
+++ b/core/modules/filter/filter.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/filter/filter.install b/core/modules/filter/filter.install
index da9ecb8..7250e53 100644
--- a/core/modules/filter/filter.install
+++ b/core/modules/filter/filter.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -105,7 +106,7 @@ function filter_schema() {
     ),
   );
 
-  $schema['cache_filter'] = drupal_get_schema_unprocessed('system', 'cache');
+  $schema['cache_filter'] = get_schema_unprocessed('system', 'cache');
   $schema['cache_filter']['description'] = 'Cache table for the Filter module to store already filtered pieces of text, identified by text format and hash of the text.';
 
   return $schema;
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index 3b8942f..a812c7c 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use DOMDocument;
 
 /**
  * @file
@@ -95,7 +97,7 @@ function filter_menu() {
   $items['admin/config/content/formats'] = array(
     'title' => 'Text formats',
     'description' => 'Configure how content input by users is filtered, including allowed HTML tags. Also allows enabling of module-provided filters.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('filter_admin_overview'),
     'access arguments' => array('administer filters'),
     'file' => 'filter.admin.inc',
@@ -122,7 +124,7 @@ function filter_menu() {
   );
   $items['admin/config/content/formats/%filter_format/disable'] = array(
     'title' => 'Disable text format',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('filter_admin_disable', 4),
     'access callback' => '_filter_disable_format_access',
     'access arguments' => array(4),
@@ -333,10 +335,10 @@ function filter_permission() {
     if (!empty($permission)) {
       // Only link to the text format configuration page if the user who is
       // viewing this will have access to that page.
-      $format_name_replacement = user_access('administer filters') ? l($format->name, 'admin/config/content/formats/' . $format->format) : drupal_placeholder($format->name);
+      $format_name_replacement = user_access('administer filters') ? l($format->name, 'admin/config/content/formats/' . $format->format) : placeholder($format->name);
       $perms[$permission] = array(
         'title' => t("Use the !text_format text format", array('!text_format' => $format_name_replacement,)),
-        'description' => drupal_placeholder(t('Warning: This permission may have security implications depending on how the text format is configured.')),
+        'description' => placeholder(t('Warning: This permission may have security implications depending on how the text format is configured.')),
       );
     }
   }
@@ -365,7 +367,7 @@ function filter_permission_name($format) {
 function filter_modules_enabled($modules) {
   // Reset the static cache of module-provided filters, in case any of the
   // newly enabled modules defines a new filter or alters existing ones.
-  drupal_static_reset('filter_get_filters');
+  drupal_static_reset('Drupal\filter_get_filters');
 }
 
 /**
@@ -374,7 +376,7 @@ function filter_modules_enabled($modules) {
 function filter_modules_disabled($modules) {
   // Reset the static cache of module-provided filters, in case any of the
   // newly disabled modules defined or altered any filters.
-  drupal_static_reset('filter_get_filters');
+  drupal_static_reset('Drupal\filter_get_filters');
 }
 
 /**
@@ -432,8 +434,8 @@ function filter_formats($account = NULL) {
 function filter_formats_reset() {
   cache()->deletePrefix('filter_formats');
   cache()->deletePrefix('filter_list_format');
-  drupal_static_reset('filter_list_format');
-  drupal_static_reset('filter_formats');
+  drupal_static_reset('Drupal\filter_list_format');
+  drupal_static_reset('Drupal\filter_formats');
 }
 
 /**
@@ -577,9 +579,9 @@ function filter_get_filters() {
       }
     }
     // Allow modules to alter filter definitions.
-    drupal_alter('filter_info', $filters);
+    alter('filter_info', $filters);
 
-    uasort($filters, '_filter_list_cmp');
+    uasort($filters, 'Drupal\_filter_list_cmp');
   }
 
   return $filters;
@@ -747,7 +749,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE)
   // Give filters the chance to escape HTML-like data such as code or formulas.
   foreach ($filters as $name => $filter) {
     if ($filter->status && isset($filter_info[$name]['prepare callback'])) {
-      $function = $filter_info[$name]['prepare callback'];
+      $function = 'Drupal\\' . $filter_info[$name]['prepare callback'];
       $text = $function($text, $filter, $format, $langcode, $cache, $cache_id);
     }
   }
@@ -755,7 +757,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE)
   // Perform filtering.
   foreach ($filters as $name => $filter) {
     if ($filter->status && isset($filter_info[$name]['process callback'])) {
-      $function = $filter_info[$name]['process callback'];
+      $function = 'Drupal\\' . $filter_info[$name]['process callback'];
       $text = $function($text, $filter, $format, $langcode, $cache, $cache_id);
     }
   }
@@ -835,7 +837,7 @@ function filter_process_format($element) {
   $element['value'] += element_info($element['#base_type']);
 
   // Turn original element into a text format wrapper.
-  $path = drupal_get_path('module', 'filter');
+  $path = get_path('module', 'filter');
   $element['#attached']['js'][] = $path . '/filter.js';
   $element['#attached']['css'][] = $path . '/filter.css';
 
@@ -1016,7 +1018,8 @@ function _filter_tips($format_id, $long = FALSE) {
     $tips[$format->name] = array();
     foreach ($filters as $name => $filter) {
       if ($filter->status && isset($filter_info[$name]['tips callback'])) {
-        $tip = $filter_info[$name]['tips callback']($filter, $format, $long);
+        $function = 'Drupal\\' . $filter_info[$name]['tips callback'];
+        $tip = $function($filter, $format, $long);
         if (isset($tip)) {
           $tips[$format->name][$name] = array('tip' => $tip, 'id' => $name);
         }
@@ -1090,7 +1093,7 @@ function filter_dom_serialize($dom_document) {
  * throw exceptions.
  *
  * This function attempts to solve the problem by creating a DocumentFragment
- * and imitating the behavior in drupal_get_js(), commenting the CDATA tag.
+ * and imitating the behavior in get_js(), commenting the CDATA tag.
  *
  * @param $dom_document
  *   The DOMDocument containing the $dom_element.
@@ -1104,7 +1107,7 @@ function filter_dom_serialize($dom_document) {
 function filter_dom_serialize_escape_cdata_element($dom_document, $dom_element, $comment_start = '//', $comment_end = '') {
   foreach ($dom_element->childNodes as $node) {
     if (get_class($node) == 'DOMCdataSection') {
-      // See drupal_get_js().  This code is more or less duplicated there.
+      // See get_js().  This code is more or less duplicated there.
       $embed_prefix = "\n<!--{$comment_start}--><![CDATA[{$comment_start} ><!--{$comment_end}\n";
       $embed_suffix = "\n{$comment_start}--><!]]>{$comment_end}\n";
 
@@ -1144,7 +1147,7 @@ function theme_filter_guidelines($variables) {
   $format = $variables['format'];
   $attributes['class'][] = 'filter-guidelines-item';
   $attributes['class'][] = 'filter-guidelines-' . $format->format;
-  $output = '<div' . drupal_attributes($attributes) . '>';
+  $output = '<div' . attributes($attributes) . '>';
   $output .= '<h3>' . check_plain($format->name) . '</h3>';
   $output .= theme('filter_tips', array('tips' => _filter_tips($format->format, FALSE)));
   $output .= '</div>';
@@ -1433,7 +1436,7 @@ function _filter_url($text, $filter) {
     // markup, especially a '>'. Therefore, remove all comment contents and add
     // them back later.
     _filter_url_escape_comments('', TRUE);
-    $text = preg_replace_callback('`<!--(.*?)-->`s', '_filter_url_escape_comments', $text);
+    $text = preg_replace_callback('`<!--(.*?)-->`s', 'Drupal\_filter_url_escape_comments', $text);
 
     // Split at all tags; ensures that no tags or attributes are processed.
     $chunks = preg_split('/(<.+?>)/is', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
@@ -1452,7 +1455,7 @@ function _filter_url($text, $filter) {
         if ($open_tag == '') {
           // If there is a match, inject a link into this chunk via the callback
           // function contained in $task.
-          $chunks[$i] = preg_replace_callback($pattern, $task, $chunks[$i]);
+          $chunks[$i] = preg_replace_callback($pattern, 'Drupal\\' . $task, $chunks[$i]);
         }
         // Text chunk is done, so next chunk must be a tag.
         $chunk_type = 'tag';
@@ -1479,7 +1482,7 @@ function _filter_url($text, $filter) {
     $text = implode($chunks);
     // Revert back to the original comment contents
     _filter_url_escape_comments('', FALSE);
-    $text = preg_replace_callback('`<!--(.*?)-->`', '_filter_url_escape_comments', $text);
+    $text = preg_replace_callback('`<!--(.*?)-->`', 'Drupal\_filter_url_escape_comments', $text);
   }
 
   return $text;
diff --git a/core/modules/filter/filter.pages.inc b/core/modules/filter/filter.pages.inc
index dbbbe4c..a3855d8 100644
--- a/core/modules/filter/filter.pages.inc
+++ b/core/modules/filter/filter.pages.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -63,7 +64,7 @@ function theme_filter_tips($variables) {
     }
     foreach ($tips as $name => $tiplist) {
       if ($multiple) {
-        $output .= '<div class="filter-type filter-' . drupal_html_class($name) . '">';
+        $output .= '<div class="filter-type filter-' . html_class($name) . '">';
         $output .= '<h3>' . $name . '</h3>';
       }
 
diff --git a/core/modules/filter/filter.test b/core/modules/filter/filter.test
index 2bafd47..2aebf63 100644
--- a/core/modules/filter/filter.test
+++ b/core/modules/filter/filter.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -8,7 +10,7 @@
 /**
  * Tests for text format and filter CRUD operations.
  */
-class FilterCRUDTestCase extends DrupalWebTestCase {
+class FilterCRUDTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Filter CRUD operations',
@@ -160,7 +162,7 @@ class FilterCRUDTestCase extends DrupalWebTestCase {
   }
 }
 
-class FilterAdminTestCase extends DrupalWebTestCase {
+class FilterAdminTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Filter administration functionality',
@@ -320,7 +322,7 @@ class FilterAdminTestCase extends DrupalWebTestCase {
     $this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration'));
     $this->assertRaw(t('Added text format %format.', array('%format' => $edit['name'])), t('New filter created.'));
 
-    drupal_static_reset('filter_formats');
+    drupal_static_reset('Drupal\filter_formats');
     $format = filter_format_load($edit['format']);
     $this->assertNotNull($format, t('Format found in database.'));
 
@@ -401,7 +403,7 @@ class FilterAdminTestCase extends DrupalWebTestCase {
   }
 }
 
-class FilterFormatAccessTestCase extends DrupalWebTestCase {
+class FilterFormatAccessTestCase extends WebTestCase {
   protected $admin_user;
   protected $filter_admin_user;
   protected $web_user;
@@ -646,7 +648,7 @@ class FilterFormatAccessTestCase extends DrupalWebTestCase {
   }
 }
 
-class FilterDefaultFormatTestCase extends DrupalWebTestCase {
+class FilterDefaultFormatTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Default text format functionality',
@@ -706,7 +708,7 @@ class FilterDefaultFormatTestCase extends DrupalWebTestCase {
   }
 }
 
-class FilterNoFormatTestCase extends DrupalWebTestCase {
+class FilterNoFormatTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Unassigned text format functionality',
@@ -729,7 +731,7 @@ class FilterNoFormatTestCase extends DrupalWebTestCase {
 /**
  * Security tests for missing/vanished text formats or filters.
  */
-class FilterSecurityTestCase extends DrupalWebTestCase {
+class FilterSecurityTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Security',
@@ -778,7 +780,7 @@ class FilterSecurityTestCase extends DrupalWebTestCase {
 /**
  * Unit tests for core filters.
  */
-class FilterUnitTestCase extends DrupalUnitTestCase {
+class FilterUnitTestCase extends UnitTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Filter module filters',
@@ -793,7 +795,7 @@ class FilterUnitTestCase extends DrupalUnitTestCase {
   function testLineBreakFilter() {
     // Setup dummy filter object.
     $filter = new stdClass();
-    $filter->callback = '_filter_autop';
+    $filter->callback = 'Drupal\_filter_autop';
 
     // Since the line break filter naturally needs plenty of newlines in test
     // strings and expectations, we're using "\n" instead of regular newlines
@@ -1157,7 +1159,7 @@ class FilterUnitTestCase extends DrupalUnitTestCase {
   function testHtmlEscapeFilter() {
     // Setup dummy filter object.
     $filter = new stdClass();
-    $filter->callback = '_filter_html_escape';
+    $filter->callback = 'Drupal\_filter_html_escape';
 
     $tests = array(
       "   One. <!-- \"comment\" --> Two'.\n<p>Three.</p>\n    " => array(
@@ -1175,7 +1177,7 @@ class FilterUnitTestCase extends DrupalUnitTestCase {
   function testUrlFilter() {
     // Setup dummy filter object.
     $filter = new stdClass();
-    $filter->callback = '_filter_url';
+    $filter->callback = 'Drupal\_filter_url';
     $filter->settings = array(
       'filter_url_length' => 496,
     );
@@ -1513,7 +1515,7 @@ www.example.com with a newline in comments -->
     $filter->settings = array(
       'filter_url_length' => 496,
     );
-    $path = drupal_get_path('module', 'filter') . '/tests';
+    $path = get_path('module', 'filter') . '/tests';
 
     $input = file_get_contents($path . '/filter.url-input.txt');
     $expected = file_get_contents($path . '/filter.url-output.txt');
@@ -1764,7 +1766,7 @@ body {color:red}
 /**
  * Tests for filter hook invocation.
  */
-class FilterHooksTestCase extends DrupalWebTestCase {
+class FilterHooksTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Filter format hooks',
diff --git a/core/modules/forum/forum-icon.tpl.php b/core/modules/forum/forum-icon.tpl.php
index 9cf2cd8..0cbe9f3 100644
--- a/core/modules/forum/forum-icon.tpl.php
+++ b/core/modules/forum/forum-icon.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/forum/forum-list.tpl.php b/core/modules/forum/forum-list.tpl.php
index 257cea9..127208c 100644
--- a/core/modules/forum/forum-list.tpl.php
+++ b/core/modules/forum/forum-list.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/forum/forum-submitted.tpl.php b/core/modules/forum/forum-submitted.tpl.php
index d310448..4ef8865 100644
--- a/core/modules/forum/forum-submitted.tpl.php
+++ b/core/modules/forum/forum-submitted.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/forum/forum-topic-list.tpl.php b/core/modules/forum/forum-topic-list.tpl.php
index 3390703..3c8cb4f 100644
--- a/core/modules/forum/forum-topic-list.tpl.php
+++ b/core/modules/forum/forum-topic-list.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/forum/forum.admin.inc b/core/modules/forum/forum.admin.inc
index a9a2dd9..6b8e97c 100644
--- a/core/modules/forum/forum.admin.inc
+++ b/core/modules/forum/forum.admin.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -7,14 +8,14 @@
 function forum_form_main($type, $edit = array()) {
   $edit = (array) $edit;
   if ((isset($_POST['op']) && $_POST['op'] == t('Delete')) || !empty($_POST['confirm'])) {
-    return drupal_get_form('forum_confirm_delete', $edit['tid']);
+    return get_form('forum_confirm_delete', $edit['tid']);
   }
   switch ($type) {
     case 'forum':
-      return drupal_get_form('forum_form_forum', $edit);
+      return get_form('forum_form_forum', $edit);
       break;
     case 'container':
-      return drupal_get_form('forum_form_container', $edit);
+      return get_form('forum_form_container', $edit);
       break;
   }
 }
@@ -89,10 +90,10 @@ function forum_form_submit($form, &$form_state) {
         variable_set('forum_containers', $containers);
       }
       $form_state['values']['tid'] = $term->tid;
-      drupal_set_message(t('Created new @type %term.', array('%term' => $form_state['values']['name'], '@type' => $type)));
+      set_message(t('Created new @type %term.', array('%term' => $form_state['values']['name'], '@type' => $type)));
       break;
     case SAVED_UPDATED:
-      drupal_set_message(t('The @type %term has been updated.', array('%term' => $form_state['values']['name'], '@type' => $type)));
+      set_message(t('The @type %term has been updated.', array('%term' => $form_state['values']['name'], '@type' => $type)));
       // Clear the page and block caches to avoid stale data.
       cache_clear_all();
       break;
@@ -114,7 +115,7 @@ function forum_form_submit($form, &$form_state) {
  * @ingroup themeable
  */
 function theme_forum_form($variables) {
-  return drupal_render_children($variables['form']);
+  return render_children($variables['form']);
 }
 
 /**
@@ -194,7 +195,7 @@ function forum_confirm_delete($form, &$form_state, $tid) {
  */
 function forum_confirm_delete_submit($form, &$form_state) {
   taxonomy_term_delete($form_state['values']['tid']);
-  drupal_set_message(t('The forum %term and all sub-forums have been deleted.', array('%term' => $form_state['values']['name'])));
+  set_message(t('The forum %term and all sub-forums have been deleted.', array('%term' => $form_state['values']['name'])));
   watchdog('content', 'forum: deleted %term and all its sub-forums.', array('%term' => $form_state['values']['name']));
 
   $form_state['redirect'] = 'admin/structure/forum';
@@ -207,14 +208,14 @@ function forum_confirm_delete_submit($form, &$form_state) {
  * @see system_settings_form()
  */
 function forum_admin_settings($form) {
-  $number = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500));
+  $number = map_assoc(array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500));
   $form['forum_hot_topic'] = array('#type' => 'select',
     '#title' => t('Hot topic threshold'),
     '#default_value' => variable_get('forum_hot_topic', 15),
     '#options' => $number,
     '#description' => t('The number of replies a topic must have to be considered "hot".'),
   );
-  $number = drupal_map_assoc(array(10, 25, 50, 75, 100));
+  $number = map_assoc(array(10, 25, 50, 75, 100));
   $form['forum_per_page'] = array('#type' => 'select',
     '#title' => t('Topics per page'),
     '#default_value' => variable_get('forum_per_page', 25),
diff --git a/core/modules/forum/forum.install b/core/modules/forum/forum.install
index 2eebd7f..821277a 100644
--- a/core/modules/forum/forum.install
+++ b/core/modules/forum/forum.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -104,7 +105,7 @@ function forum_enable() {
  */
 function forum_uninstall() {
   // Load the dependent Taxonomy module, in case it has been disabled.
-  drupal_load('module', 'taxonomy');
+  load('module', 'taxonomy');
 
   variable_del('forum_containers');
   variable_del('forum_hot_topic');
diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module
index b334c42..efece07 100644
--- a/core/modules/forum/forum.module
+++ b/core/modules/forum/forum.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -103,7 +105,7 @@ function forum_menu() {
   $items['admin/structure/forum'] = array(
     'title' => 'Forums',
     'description' => 'Control forum hierarchy settings.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('forum_overview'),
     'access arguments' => array('administer forums'),
     'file' => 'forum.admin.inc',
@@ -133,7 +135,7 @@ function forum_menu() {
   );
   $items['admin/structure/forum/settings'] = array(
     'title' => 'Settings',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('forum_admin_settings'),
     'access arguments' => array('administer forums'),
     'weight' => 5,
@@ -199,7 +201,7 @@ function forum_menu_local_tasks_alter(&$data, $router_item, $root_path) {
             '#theme' => 'menu_local_action',
             '#link' => array(
               'title' => t('<a href="@login">Log in</a> to post new content in the forum.', array(
-                '@login' => url('user/login', array('query' => drupal_get_destination())),
+                '@login' => url('user/login', array('query' => get_destination())),
               )),
               'localized_options' => array('html' => TRUE),
             ),
@@ -274,7 +276,7 @@ function forum_node_view($node, $view_mode) {
           $breadcrumb[] = l($parent->name, 'forum/' . $parent->tid);
         }
       }
-      drupal_set_breadcrumb($breadcrumb);
+      set_breadcrumb($breadcrumb);
 
     }
   }
@@ -621,12 +623,12 @@ function forum_form_node_form_alter(&$form, &$form_state, $form_id) {
 function forum_block_info() {
   $blocks['active'] = array(
     'info' => t('Active forum topics'),
-    'cache' => DRUPAL_CACHE_CUSTOM,
+    'cache' => CACHE_CUSTOM,
     'properties' => array('administrative' => TRUE),
   );
   $blocks['new'] = array(
     'info' => t('New forum topics'),
-    'cache' => DRUPAL_CACHE_CUSTOM,
+    'cache' => CACHE_CUSTOM,
     'properties' => array('administrative' => TRUE),
   );
   return $blocks;
@@ -636,7 +638,7 @@ function forum_block_info() {
  * Implements hook_block_configure().
  */
 function forum_block_configure($delta = '') {
-  $form['forum_block_num_' . $delta] = array('#type' => 'select', '#title' => t('Number of topics'), '#default_value' => variable_get('forum_block_num_' . $delta, '5'), '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)));
+  $form['forum_block_num_' . $delta] = array('#type' => 'select', '#title' => t('Number of topics'), '#default_value' => variable_get('forum_block_num_' . $delta, '5'), '#options' => map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)));
   return $form;
 }
 
@@ -675,7 +677,7 @@ function forum_block_view($delta = '') {
 
   $block['subject'] = $title;
   // Cache based on the altered query. Enables us to cache with node access enabled.
-  $block['content'] = drupal_render_cache_by_query($query, 'forum_block_view');
+  $block['content'] = render_cache_by_query($query, 'forum_block_view');
   $block['content']['#access'] = user_access('access content');
   return $block;
 }
@@ -1006,8 +1008,8 @@ function template_preprocess_forums(&$variables) {
       }
     }
   }
-  drupal_set_breadcrumb($breadcrumb);
-  drupal_set_title($title);
+  set_breadcrumb($breadcrumb);
+  set_title($title);
 
   if ($variables['forums_defined'] = count($variables['forums']) || count($variables['parents'])) {
     if (!empty($variables['forums'])) {
@@ -1019,7 +1021,7 @@ function template_preprocess_forums(&$variables) {
 
     if ($variables['tid'] && !in_array($variables['tid'], variable_get('forum_containers', array()))) {
       $variables['topics'] = theme('forum_topic_list', $variables);
-      drupal_add_feed('taxonomy/term/' . $variables['tid'] . '/feed', 'RSS - ' . $title);
+      add_feed('taxonomy/term/' . $variables['tid'] . '/feed', 'RSS - ' . $title);
     }
     else {
       $variables['topics'] = '';
@@ -1043,7 +1045,7 @@ function template_preprocess_forums(&$variables) {
 
   }
   else {
-    drupal_set_title(t('No forums defined'));
+    set_title(t('No forums defined'));
     $variables['forums'] = '';
     $variables['topics'] = '';
   }
diff --git a/core/modules/forum/forum.pages.inc b/core/modules/forum/forum.pages.inc
index 29307e7..cda7f93 100644
--- a/core/modules/forum/forum.pages.inc
+++ b/core/modules/forum/forum.pages.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/forum/forum.test b/core/modules/forum/forum.test
index c7c3d9c..ce4dd97 100644
--- a/core/modules/forum/forum.test
+++ b/core/modules/forum/forum.test
@@ -1,11 +1,12 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
  * Tests for forum.module.
  */
 
-class ForumTestCase extends DrupalWebTestCase {
+class ForumTestCase extends WebTestCase {
   protected $admin_user;
   protected $edit_own_topics_user;
   protected $edit_any_topics_user;
@@ -281,7 +282,7 @@ class ForumTestCase extends DrupalWebTestCase {
 
     // Restore the original vocabulary.
     taxonomy_vocabulary_save($original_settings);
-    drupal_static_reset('taxonomy_vocabulary_load');
+    drupal_static_reset('Drupal\taxonomy_vocabulary_load');
     $current_settings = taxonomy_vocabulary_load($vid);
     $this->assertEqual($current_settings->name, $original_settings->name, 'The original vocabulary settings were restored');
   }
diff --git a/core/modules/forum/forums.tpl.php b/core/modules/forum/forums.tpl.php
index 55a760f..94e2462 100644
--- a/core/modules/forum/forums.tpl.php
+++ b/core/modules/forum/forums.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/help/help.admin.inc b/core/modules/help/help.admin.inc
index b37819b..48df0af 100644
--- a/core/modules/help/help.admin.inc
+++ b/core/modules/help/help.admin.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -14,7 +15,7 @@
  */
 function help_main() {
   // Add CSS
-  drupal_add_css(drupal_get_path('module', 'help') . '/help.css');
+  add_css(get_path('module', 'help') . '/help.css');
   $output = '<h2>' . t('Help topics') . '</h2><p>' . t('Help is available on the following items:') . '</p>' . help_links_as_list();
   return $output;
 }
@@ -33,9 +34,9 @@ function help_page($name) {
   $output = '';
   if (module_hook($name, 'help')) {
     $info = system_get_info('module');
-    drupal_set_title($info[$name]['name']);
+    set_title($info[$name]['name']);
 
-    $temp = module_invoke($name, 'help', "admin/help#$name", drupal_help_arg());
+    $temp = module_invoke($name, 'help', "admin/help#$name", help_arg());
     if (empty($temp)) {
       $output .= t("No help is available for module %module.", array('%module' => $info[$name]['name']));
     }
@@ -64,7 +65,7 @@ function help_page($name) {
  *   A string containing the formatted list.
  */
 function help_links_as_list() {
-  $empty_arg = drupal_help_arg();
+  $empty_arg = help_arg();
   $module_info = system_rebuild_module_data();
 
   $modules = array();
diff --git a/core/modules/help/help.api.php b/core/modules/help/help.api.php
index f7d9c08..7e944df 100644
--- a/core/modules/help/help.api.php
+++ b/core/modules/help/help.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/help/help.module b/core/modules/help/help.module
index 69978c6..315e207 100644
--- a/core/modules/help/help.module
+++ b/core/modules/help/help.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/help/help.test b/core/modules/help/help.test
index a37afb2..8874469 100644
--- a/core/modules/help/help.test
+++ b/core/modules/help/help.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -8,7 +9,7 @@
 /**
  * Tests help display and user access for all modules implementing help.
  */
-class HelpTestCase extends DrupalWebTestCase {
+class HelpTestCase extends WebTestCase {
   /**
    * The admin user that will be created.
    */
@@ -52,7 +53,7 @@ class HelpTestCase extends DrupalWebTestCase {
     // Check for css on admin/help.
     $this->drupalLogin($this->big_user);
     $this->drupalGet('admin/help');
-    $this->assertRaw(drupal_get_path('module', 'help') . '/help.css', t('The help.css file is present in the HTML.'));
+    $this->assertRaw(get_path('module', 'help') . '/help.css', t('The help.css file is present in the HTML.'));
 
     // Verify that introductory help text exists, goes for 100% module coverage.
     $this->assertRaw(t('For more information, refer to the specific topics listed in the next section or to the <a href="@drupal">online Drupal handbooks</a>.', array('@drupal' => 'http://drupal.org/handbooks')), 'Help intro text correctly appears.');
@@ -94,7 +95,7 @@ class HelpTestCase extends DrupalWebTestCase {
     $this->modules = array();
     $result = db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC");
     foreach ($result as $module) {
-      if (file_exists($module->filename) && function_exists($module->name . '_help')) {
+      if (file_exists($module->filename) && function_exists('Drupal\\' . $module->name . '_help')) {
         $fullname = unserialize($module->info);
         $this->modules[$module->name] = $fullname['name'];
       }
@@ -105,7 +106,7 @@ class HelpTestCase extends DrupalWebTestCase {
 /**
  * Tests a module without help to verify it is not listed in the help page.
  */
-class NoHelpTestCase extends DrupalWebTestCase {
+class NoHelpTestCase extends WebTestCase {
   /**
    * The user who will be created.
    */
diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc
index 9643841..50a60b2 100644
--- a/core/modules/image/image.admin.inc
+++ b/core/modules/image/image.admin.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -15,7 +16,7 @@ function image_style_list() {
   $page['image_style_list'] = array(
     '#markup' => theme('image_style_list', array('styles' => $styles)),
     '#attached' => array(
-      'css' => array(drupal_get_path('module', 'image') . '/image.admin.css' => array()),
+      'css' => array(get_path('module', 'image') . '/image.admin.css' => array()),
     ),
   );
 
@@ -36,18 +37,18 @@ function image_style_list() {
  */
 function image_style_form($form, &$form_state, $style) {
   $title = t('Edit %name style', array('%name' => $style['name']));
-  drupal_set_title($title, PASS_THROUGH);
+  set_title($title, PASS_THROUGH);
 
   // Adjust this form for styles that must be overridden to edit.
   $editable = (bool) ($style['storage'] & IMAGE_STORAGE_EDITABLE);
 
   if (!$editable && empty($form_state['input'])) {
-    drupal_set_message(t('This image style is currently being provided by a module. Click the "Override defaults" button to change its settings.'), 'warning');
+    set_message(t('This image style is currently being provided by a module. Click the "Override defaults" button to change its settings.'), 'warning');
   }
 
   $form_state['image_style'] = $style;
   $form['#tree'] = TRUE;
-  $form['#attached']['css'][drupal_get_path('module', 'image') . '/image.admin.css'] = array();
+  $form['#attached']['css'][get_path('module', 'image') . '/image.admin.css'] = array();
 
   // Show the thumbnail preview.
   $form['preview'] = array(
@@ -191,7 +192,7 @@ function image_style_form_add_submit($form, &$form_state) {
     $effect['isid'] = $style['isid'];
     $effect['weight'] = $form_state['values']['weight'];
     image_effect_save($effect);
-    drupal_set_message(t('The image effect was successfully applied.'));
+    set_message(t('The image effect was successfully applied.'));
   }
 }
 
@@ -199,7 +200,7 @@ function image_style_form_add_submit($form, &$form_state) {
  * Submit handler for overriding a module-defined style.
  */
 function image_style_form_override_submit($form, &$form_state) {
-  drupal_set_message(t('The %style style has been overridden, allowing you to change its settings.', array('%style' => $form_state['image_style']['name'])));
+  set_message(t('The %style style has been overridden, allowing you to change its settings.', array('%style' => $form_state['image_style']['name'])));
   image_default_style_save($form_state['image_style']);
 }
 
@@ -226,7 +227,7 @@ function image_style_form_submit($form, &$form_state) {
 
   image_style_save($style);
   if ($form_state['values']['op'] == t('Update style')) {
-    drupal_set_message(t('Changes to the style have been saved.'));
+    set_message(t('Changes to the style have been saved.'));
   }
   $form_state['redirect'] = 'admin/config/media/image-styles/edit/' . $style['name'];
 }
@@ -263,7 +264,7 @@ function image_style_add_form($form, &$form_state) {
 function image_style_add_form_submit($form, &$form_state) {
   $style = array('name' => $form_state['values']['name']);
   $style = image_style_save($style);
-  drupal_set_message(t('Style %name was created.', array('%name' => $style['name'])));
+  set_message(t('Style %name was created.', array('%name' => $style['name'])));
   $form_state['redirect'] = 'admin/config/media/image-styles/edit/' . $style['name'];
 }
 
@@ -319,7 +320,7 @@ function image_style_delete_form_submit($form, &$form_state) {
   $style = $form_state['image_style'];
 
   image_style_delete($style, $form_state['values']['replacement']);
-  drupal_set_message(t('Style %name was deleted.', array('%name' => $style['name'])));
+  set_message(t('Style %name was deleted.', array('%name' => $style['name'])));
   $form_state['redirect'] = 'admin/config/media/image-styles';
 }
 
@@ -342,7 +343,7 @@ function image_style_revert_form($form, $form_state, $style) {
  * Submit handler to convert an overridden style to its default.
  */
 function image_style_revert_form_submit($form, &$form_state) {
-  drupal_set_message(t('The %style style has been reverted to its defaults.', array('%style' => $form_state['image_style']['name'])));
+  set_message(t('The %style style has been reverted to its defaults.', array('%style' => $form_state['image_style']['name'])));
   image_default_style_revert($form_state['image_style']);
   $form_state['redirect'] = 'admin/config/media/image-styles';
 }
@@ -377,20 +378,20 @@ function image_effect_form($form, &$form_state, $style, $effect) {
   else{
     $title = t('Add %label effect', array('%label' => $effect['label']));
   }
-  drupal_set_title($title, PASS_THROUGH);
+  set_title($title, PASS_THROUGH);
 
   $form_state['image_style'] = $style;
   $form_state['image_effect'] = $effect;
 
   // If no configuration for this image effect, return to the image style page.
   if (!isset($effect['form callback'])) {
-    drupal_goto('admin/config/media/image-styles/edit/' . $style['name']);
+    redirect('admin/config/media/image-styles/edit/' . $style['name']);
   }
 
   $form['#tree'] = TRUE;
-  $form['#attached']['css'][drupal_get_path('module', 'image') . '/image.admin.css'] = array();
+  $form['#attached']['css'][get_path('module', 'image') . '/image.admin.css'] = array();
 
-  $form['data'] = call_user_func($effect['form callback'], $effect['data']);
+  $form['data'] = call_user_func('Drupal\\' . $effect['form callback'], $effect['data']);
 
   // Check the URL for a weight, then the image effect, otherwise use default.
   $form['weight'] = array(
@@ -420,7 +421,7 @@ function image_effect_form_submit($form, &$form_state) {
   $effect = array_merge($form_state['image_effect'], $form_state['values']);
   $effect['isid'] = $style['isid'];
   image_effect_save($effect);
-  drupal_set_message(t('The image effect was successfully applied.'));
+  set_message(t('The image effect was successfully applied.'));
   $form_state['redirect'] = 'admin/config/media/image-styles/edit/' . $style['name'];
 }
 
@@ -450,7 +451,7 @@ function image_effect_delete_form_submit($form, &$form_state) {
   $effect = $form_state['image_effect'];
 
   image_effect_delete($effect);
-  drupal_set_message(t('The image effect %name has been deleted.', array('%name' => $effect['label'])));
+  set_message(t('The image effect %name has been deleted.', array('%name' => $effect['label'])));
   $form_state['redirect'] = 'admin/config/media/image-styles/edit/' . $style['name'];
 }
 
@@ -736,7 +737,7 @@ function theme_image_style_effects($variables) {
   }
 
   $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'image-style-effects')));
-  drupal_add_tabledrag('image-style-effects', 'order', 'sibling', 'image-effect-order-weight');
+  add_tabledrag('image-style-effects', 'order', 'sibling', 'image-effect-order-weight');
   return $output;
 }
 
@@ -752,7 +753,7 @@ function theme_image_style_effects($variables) {
 function theme_image_style_preview($variables) {
   $style = $variables['style'];
 
-  $sample_image = variable_get('image_style_preview_image', drupal_get_path('module', 'image') . '/sample.png');
+  $sample_image = variable_get('image_style_preview_image', get_path('module', 'image') . '/sample.png');
   $sample_width = 160;
   $sample_height = 160;
 
diff --git a/core/modules/image/image.api.php b/core/modules/image/image.api.php
index 758d38b..86118f3 100644
--- a/core/modules/image/image.api.php
+++ b/core/modules/image/image.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/image/image.effects.inc b/core/modules/image/image.effects.inc
index 35a6a74..9753ac0 100644
--- a/core/modules/image/image.effects.inc
+++ b/core/modules/image/image.effects.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/image/image.field.inc b/core/modules/image/image.field.inc
index aef6be7..d46567d 100644
--- a/core/modules/image/image.field.inc
+++ b/core/modules/image/image.field.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -354,7 +355,7 @@ function image_field_widget_process($element, &$form_state, $form) {
   $widget_settings = $instance['widget']['settings'];
 
   $element['#theme'] = 'image_widget';
-  $element['#attached']['css'][] = drupal_get_path('module', 'image') . '/image.css';
+  $element['#attached']['css'][] = get_path('module', 'image') . '/image.css';
 
   // Add the image preview.
   if ($element['#file'] && $widget_settings['preview_image_style']) {
@@ -445,7 +446,7 @@ function theme_image_widget($variables) {
   if ($element['fid']['#value'] != 0) {
     $element['filename']['#markup'] .= ' <span class="file-size">(' . format_size($element['#file']->filesize) . ')</span> ';
   }
-  $output .= drupal_render_children($element);
+  $output .= render_children($element);
   $output .= '</div>';
   $output .= '</div>';
 
diff --git a/core/modules/image/image.install b/core/modules/image/image.install
index 02be57c..7716a91 100644
--- a/core/modules/image/image.install
+++ b/core/modules/image/image.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/image/image.module b/core/modules/image/image.module
index f39a2a0..01fead1 100644
--- a/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use PDO;
 
 /**
  * @file
@@ -31,7 +33,7 @@ define('IMAGE_STORAGE_EDITABLE', IMAGE_STORAGE_NORMAL | IMAGE_STORAGE_OVERRIDE);
 define('IMAGE_STORAGE_MODULE', IMAGE_STORAGE_OVERRIDE | IMAGE_STORAGE_DEFAULT);
 
 // Load all Field module hooks for Image.
-require_once DRUPAL_ROOT . '/core/modules/image/image.field.inc';
+require_once ROOT . '/core/modules/image/image.field.inc';
 
 /**
  * Implement of hook_help().
@@ -111,7 +113,7 @@ function image_menu() {
   $items['admin/config/media/image-styles/add'] = array(
     'title' => 'Add style',
     'description' => 'Add a new image style.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('image_style_add_form'),
     'access arguments' => array('administer image styles'),
     'type' => MENU_LOCAL_ACTION,
@@ -121,7 +123,7 @@ function image_menu() {
   $items['admin/config/media/image-styles/edit/%image_style'] = array(
     'title' => 'Edit style',
     'description' => 'Configure an image style.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('image_style_form', 5),
     'access arguments' => array('administer image styles'),
     'file' => 'image.admin.inc',
@@ -130,7 +132,7 @@ function image_menu() {
     'title' => 'Delete style',
     'description' => 'Delete an image style.',
     'load arguments' => array(NULL, (string) IMAGE_STORAGE_NORMAL),
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('image_style_delete_form', 5),
     'access arguments' => array('administer image styles'),
     'file' => 'image.admin.inc',
@@ -139,7 +141,7 @@ function image_menu() {
     'title' => 'Revert style',
     'description' => 'Revert an image style.',
     'load arguments' => array(NULL, (string) IMAGE_STORAGE_OVERRIDE),
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('image_style_revert_form', 5),
     'access arguments' => array('administer image styles'),
     'file' => 'image.admin.inc',
@@ -148,7 +150,7 @@ function image_menu() {
     'title' => 'Edit image effect',
     'description' => 'Edit an existing effect within a style.',
     'load arguments' => array(5, (string) IMAGE_STORAGE_EDITABLE),
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('image_effect_form', 5, 7),
     'access arguments' => array('administer image styles'),
     'file' => 'image.admin.inc',
@@ -157,7 +159,7 @@ function image_menu() {
     'title' => 'Delete image effect',
     'description' => 'Delete an existing effect from a style.',
     'load arguments' => array(5, (string) IMAGE_STORAGE_EDITABLE),
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('image_effect_delete_form', 5, 7),
     'access arguments' => array('administer image styles'),
     'file' => 'image.admin.inc',
@@ -166,7 +168,7 @@ function image_menu() {
     'title' => 'Add image effect',
     'description' => 'Add a new effect to a style.',
     'load arguments' => array(5),
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('image_effect_form', 5, 7),
     'access arguments' => array('administer image styles'),
     'file' => 'image.admin.inc',
@@ -528,7 +530,7 @@ function image_styles() {
         $styles[$style_name] = $style;
       }
 
-      drupal_alter('image_styles', $styles);
+      alter('image_styles', $styles);
       cache()->set('image_styles', $styles);
     }
   }
@@ -595,13 +597,13 @@ function image_style_save($style) {
     // Load the existing style to make sure we account for renamed styles.
     $old_style = image_style_load(NULL, $style['isid']);
     image_style_flush($old_style);
-    drupal_write_record('image_styles', $style, 'isid');
+    write_record('image_styles', $style, 'isid');
     if ($old_style['name'] != $style['name']) {
       $style['old_name'] = $old_style['name'];
     }
   }
   else {
-    drupal_write_record('image_styles', $style);
+    write_record('image_styles', $style);
     $style['is_new'] = TRUE;
   }
 
@@ -675,7 +677,7 @@ function image_style_options($include_empty = TRUE) {
   if ($include_empty && !empty($styles)) {
     $options[''] = t('<none>');
   }
-  $options = array_merge($options, drupal_map_assoc(array_keys($styles)));
+  $options = array_merge($options, map_assoc(array_keys($styles)));
   if (empty($options)) {
     $options[''] = t('No defined styles');
   }
@@ -713,11 +715,11 @@ function image_style_deliver($style, $scheme) {
     else {
       $headers = module_invoke_all('file_download', $image_uri);
       if (in_array(-1, $headers) || empty($headers)) {
-        return drupal_access_denied();
+        return access_denied();
       }
       if (count($headers)) {
         foreach ($headers as $name => $value) {
-          drupal_add_http_header($name, $value);
+          add_http_header($name, $value);
         }
       }
     }
@@ -725,14 +727,14 @@ function image_style_deliver($style, $scheme) {
 
   // Don't start generating the image if the derivative already exists or if
   // generation is in progress in another thread.
-  $lock_name = 'image_style_deliver:' . $style['name'] . ':' . drupal_hash_base64($image_uri);
+  $lock_name = 'image_style_deliver:' . $style['name'] . ':' . hash_base64($image_uri);
   if (!file_exists($derivative_uri)) {
     $lock_acquired = lock_acquire($lock_name);
     if (!$lock_acquired) {
       // Tell client to retry again in 3 seconds. Currently no browsers are known
       // to support Retry-After.
-      drupal_add_http_header('Status', '503 Service Unavailable');
-      drupal_add_http_header('Retry-After', 3);
+      add_http_header('Status', '503 Service Unavailable');
+      add_http_header('Retry-After', 3);
       print t('Image generation in progress. Try again shortly.');
       drupal_exit();
     }
@@ -752,7 +754,7 @@ function image_style_deliver($style, $scheme) {
   }
   else {
     watchdog('image', 'Unable to generate the derived image located at %path.', array('%path' => $derivative_uri));
-    drupal_add_http_header('Status', '500 Internal Server Error');
+    add_http_header('Status', '500 Internal Server Error');
     print t('Error generating image.');
     drupal_exit();
   }
@@ -831,7 +833,8 @@ function image_style_transform_dimensions($style_name, array &$dimensions) {
     }
 
     if (isset($effect['dimensions callback'])) {
-      $effect['dimensions callback']($dimensions, $effect['data']);
+      $function = 'Drupal\\' . $effect['dimensions callback'];
+      $function($dimensions, $effect['data']);
     }
     else {
       $dimensions['width'] = $dimensions['height'] = NULL;
@@ -857,12 +860,12 @@ function image_style_flush($style) {
   // Clear image style and effect caches.
   cache()->delete('image_styles');
   cache()->deletePrefix('image_effects:');
-  drupal_static_reset('image_styles');
-  drupal_static_reset('image_effects');
+  drupal_static_reset('Drupal\image_styles');
+  drupal_static_reset('Drupal\image_effects');
 
   // Clear field caches so that formatters may be added for this style.
   field_info_cache_clear();
-  drupal_theme_rebuild();
+  theme_rebuild();
 
   // Clear page caches when flushing.
   if (module_exists('block')) {
@@ -985,7 +988,7 @@ function image_effect_definitions() {
     }
     else {
       $effects = array();
-      include_once DRUPAL_ROOT . '/core/modules/image/image.effects.inc';
+      include_once ROOT . '/core/modules/image/image.effects.inc';
       foreach (module_implements('image_effect_info') as $module) {
         foreach (module_invoke($module, 'image_effect_info') as $name => $effect) {
           // Ensure the current toolkit supports the effect.
@@ -995,8 +998,8 @@ function image_effect_definitions() {
           $effects[$name] = $effect;
         }
       }
-      uasort($effects, '_image_effect_definitions_sort');
-      drupal_alter('image_effect_info', $effects);
+      uasort($effects, 'Drupal\_image_effect_definitions_sort');
+      alter('image_effect_info', $effects);
       cache()->set("image_effects:$langcode", $effects);
     }
   }
@@ -1115,10 +1118,10 @@ function image_effect_load($ieid, $style_name, $include = NULL) {
  */
 function image_effect_save($effect) {
   if (!empty($effect['ieid'])) {
-    drupal_write_record('image_effects', $effect, 'ieid');
+    write_record('image_effects', $effect, 'ieid');
   }
   else {
-    drupal_write_record('image_effects', $effect);
+    write_record('image_effects', $effect);
   }
   $style = image_style_load(NULL, $effect['isid']);
   image_style_flush($style);
@@ -1149,7 +1152,7 @@ function image_effect_delete($effect) {
  */
 function image_effect_apply($image, $effect) {
   module_load_include('inc', 'image', 'image.effects');
-  $function = $effect['effect callback'];
+  $function = 'Drupal\\' . $effect['effect callback'];
   return $function($image, $effect['data']);
 }
 
diff --git a/core/modules/image/image.test b/core/modules/image/image.test
index 4d4532c..4ebad5c 100644
--- a/core/modules/image/image.test
+++ b/core/modules/image/image.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -28,7 +29,7 @@
 /**
  * This class provides methods specifically for testing Image's field handling.
  */
-class ImageFieldTestCase extends DrupalWebTestCase {
+class ImageFieldTestCase extends WebTestCase {
   protected $admin_user;
 
   function setUp() {
@@ -105,7 +106,7 @@ class ImageFieldTestCase extends DrupalWebTestCase {
 /**
  * Tests the functions for generating paths and URLs for image styles.
  */
-class ImageStylesPathAndUrlUnitTest extends DrupalWebTestCase {
+class ImageStylesPathAndUrlUnitTest extends WebTestCase {
   protected $style_name;
   protected $image_info;
   protected $image_filepath;
@@ -192,7 +193,7 @@ class ImageStylesPathAndUrlUnitTest extends DrupalWebTestCase {
     $this->assertNotIdentical(FALSE, $original_uri, t('Created the generated image file.'));
 
     // Get the URL of a file that has not been generated and try to create it.
-    $generated_uri = $scheme . '://styles/' . $this->style_name . '/' . $scheme . '/'. drupal_basename($original_uri);
+    $generated_uri = $scheme . '://styles/' . $this->style_name . '/' . $scheme . '/'. basename($original_uri);
     $this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
     $generate_url = image_style_url($this->style_name, $original_uri);
 
@@ -412,7 +413,7 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
     // Edit effect form.
 
     // Revisit each form to make sure the effect was saved.
-    drupal_static_reset('image_styles');
+    drupal_static_reset('Drupal\image_styles');
     $style = image_style_load($style_name);
 
     foreach ($style['effects'] as $ieid => $effect) {
@@ -467,7 +468,7 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
     $this->assertEqual($this->getImageCount($style), 0, t('Image style %style was flushed after renaming the style and updating the order of effects.', array('%style' => $style['name'])));
 
     // Load the style by the new name with the new weights.
-    drupal_static_reset('image_styles');
+    drupal_static_reset('Drupal\image_styles');
     $style = image_style_load($style_name, NULL);
 
     // Confirm the new style order was saved.
@@ -501,7 +502,7 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
     $directory = file_default_scheme() . '://styles/' . $style_name;
     $this->assertFalse(is_dir($directory), t('Image style %style directory removed on style deletion.', array('%style' => $style['name'])));
 
-    drupal_static_reset('image_styles');
+    drupal_static_reset('Drupal\image_styles');
     $this->assertFalse(image_style_load($style_name), t('Image style %style successfully deleted.', array('%style' => $style['name'])));
 
   }
@@ -527,7 +528,7 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
     $this->assertNoField('edit-add', t('Default styles may not have new effects added.'));
 
     // Create an image to make sure the default works before overriding.
-    drupal_static_reset('image_styles');
+    drupal_static_reset('Drupal\image_styles');
     $style = image_style_load($style_name);
     $image_path = $this->createSampleImage($style);
     $this->assertEqual($this->getImageCount($style), 1, t('Image style %style image %file successfully generated.', array('%style' => $style['name'], '%file' => $image_path)));
@@ -543,7 +544,7 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
 
     // Add sample effect to the overridden style.
     $this->drupalPost($edit_path, array('new' => 'image_desaturate'), t('Add'));
-    drupal_static_reset('image_styles');
+    drupal_static_reset('Drupal\image_styles');
     $style = image_style_load($style_name);
 
     // Verify that effects attached to the style have an ieid now.
@@ -567,7 +568,7 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
 
     // Revert the image style.
     $this->drupalPost($revert_path, array(), t('Revert'));
-    drupal_static_reset('image_styles');
+    drupal_static_reset('Drupal\image_styles');
     $style = image_style_load($style_name);
 
     // The style should now have the single effect for scale.
@@ -648,7 +649,7 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
    */
   function testImageFieldFormattersPrivate() {
     // Remove access content permission from anonymous users.
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array('access content' => FALSE));
+    user_role_change_permissions(ANONYMOUS_RID, array('access content' => FALSE));
     $this->_testImageFieldFormatters('private');
   }
 
@@ -749,7 +750,7 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
     $field = $this->createImageField($field_name, 'article', array(), $instance_settings, $widget_settings);
     $field['deleted'] = 0;
     $table = _field_sql_storage_tablename($field);
-    $schema = drupal_get_schema($table, TRUE);
+    $schema = get_schema($table, TRUE);
     $instance = field_info_instance('node', $field_name, 'article');
 
     $this->drupalGet('node/add/article');
@@ -934,7 +935,7 @@ class ImageFieldValidateTestCase extends ImageFieldTestCase {
 /**
  * Tests that images have correct dimensions when styled.
  */
-class ImageDimensionsUnitTest extends DrupalWebTestCase {
+class ImageDimensionsUnitTest extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -959,7 +960,7 @@ class ImageDimensionsUnitTest extends DrupalWebTestCase {
 
     // Create a style.
     $style = image_style_save(array('name' => 'test'));
-    $generated_uri = 'public://styles/test/public/'. drupal_basename($original_uri);
+    $generated_uri = 'public://styles/test/public/'. basename($original_uri);
     $url = image_style_url('test', $original_uri);
 
     $variables = array(
@@ -1152,7 +1153,7 @@ class ImageDimensionsUnitTest extends DrupalWebTestCase {
 /**
  * Tests image_dimensions_scale().
  */
-class ImageDimensionsScaleTestCase extends DrupalUnitTestCase {
+class ImageDimensionsScaleTestCase extends UnitTestCase {
   public static function getInfo() {
     return array(
       'name' => 'image_dimensions_scale()',
diff --git a/core/modules/image/tests/image_module_test.module b/core/modules/image/tests/image_module_test.module
index 766a9d9..433da5c 100644
--- a/core/modules/image/tests/image_module_test.module
+++ b/core/modules/image/tests/image_module_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc
index 33bc147..5f497ed 100644
--- a/core/modules/language/language.admin.inc
+++ b/core/modules/language/language.admin.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -9,7 +11,7 @@
  * User interface for the language overview screen.
  */
 function language_admin_overview_form($form, &$form_state) {
-  drupal_static_reset('language_list');
+  drupal_static_reset('Drupal\language_list');
   $languages = language_list();
   $default = language_default();
 
@@ -137,9 +139,9 @@ function theme_language_admin_overview_form_table($variables) {
     'rows' => $rows,
     'attributes' => array('id' => 'language-order'),
   ));
-  $output .= drupal_render_children($form);
+  $output .= render_children($form);
 
-  drupal_add_tabledrag('language-order', 'order', 'sibling', 'language-order-weight');
+  add_tabledrag('language-order', 'order', 'sibling', 'language-order-weight');
 
   return $output;
 }
@@ -166,7 +168,7 @@ function language_admin_overview_form_submit($form, &$form_state) {
     language_save($language);
   }
 
-  drupal_set_message(t('Configuration saved.'));
+  set_message(t('Configuration saved.'));
 }
 
 /**
@@ -330,7 +332,7 @@ function language_admin_add_custom_form_submit($form, &$form_state) {
     'direction' => $form_state['values']['direction'],
   );
   language_save($language);
-  drupal_set_message(t('The language %language has been created and can now be used.', array('%language' => $form_state['values']['name'])));
+  set_message(t('The language %language has been created and can now be used.', array('%language' => $form_state['values']['name'])));
   $form_state['redirect'] = 'admin/config/regional/language';
 }
 
@@ -340,13 +342,13 @@ function language_admin_add_custom_form_submit($form, &$form_state) {
 function language_admin_add_predefined_form_submit($form, &$form_state) {
   // Predefined language selection.
   $langcode = $form_state['values']['predefined_langcode'];
-  include_once DRUPAL_ROOT . '/core/includes/standard.inc';
+  include_once ROOT . '/core/includes/standard.inc';
   $predefined = standard_language_list();
   $language = (object) array(
     'langcode' => $langcode,
   );
   language_save($language);
-  drupal_set_message(t('The language %language has been created and can now be used.', array('%language' => t($predefined[$langcode][0]))));
+  set_message(t('The language %language has been created and can now be used.', array('%language' => t($predefined[$langcode][0]))));
   $form_state['redirect'] = 'admin/config/regional/language';
 }
 
@@ -384,15 +386,15 @@ function language_admin_delete_form($form, &$form_state, $language) {
   $langcode = $language->langcode;
 
   if (language_default()->langcode == $langcode) {
-    drupal_set_message(t('The default language cannot be deleted.'));
-    drupal_goto('admin/config/regional/language');
+    set_message(t('The default language cannot be deleted.'));
+    redirect('admin/config/regional/language');
   }
 
   // For other languages, warn user that data loss is ahead.
   $languages = language_list();
 
   if (!isset($languages[$langcode])) {
-    drupal_not_found();
+    not_found();
     drupal_exit();
   }
   else {
@@ -413,7 +415,7 @@ function language_admin_delete_form_submit($form, &$form_state) {
 
   if ($success) {
     $t_args = array('%language' => $language->name, '%langcode' => $language->langcode);
-    drupal_set_message(t('The %language (%langcode) language has been removed.', $t_args));
+    set_message(t('The %language (%langcode) language has been removed.', $t_args));
   }
 
   $form_state['redirect'] = 'admin/config/regional/language';
@@ -423,7 +425,7 @@ function language_admin_delete_form_submit($form, &$form_state) {
  * Prepare a language code list for unused predefined languages.
  */
 function language_admin_predefined_list() {
-  include_once DRUPAL_ROOT . '/core/includes/standard.inc';
+  include_once ROOT . '/core/includes/standard.inc';
   $languages = language_list();
   $predefined = standard_language_list();
   foreach ($predefined as $key => $value) {
diff --git a/core/modules/language/language.api.php b/core/modules/language/language.api.php
index 6f19835..2cfdaba 100644
--- a/core/modules/language/language.api.php
+++ b/core/modules/language/language.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/language/language.install b/core/modules/language/language.install
index 1375fd9..cb9de68 100644
--- a/core/modules/language/language.install
+++ b/core/modules/language/language.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -23,7 +24,7 @@ function language_uninstall() {
 
   // Re-initialize the language system so successive calls to t() and other
   // functions will not expect languages to be present.
-  drupal_language_initialize();
+  language_initialize();
 }
 
 /**
diff --git a/core/modules/language/language.module b/core/modules/language/language.module
index 44d5917..1e49a3c 100644
--- a/core/modules/language/language.module
+++ b/core/modules/language/language.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -36,7 +37,7 @@ function language_menu() {
   $items['admin/config/regional/language'] = array(
     'title' => 'Languages',
     'description' => 'Configure languages for content and the user interface.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('language_admin_overview_form'),
     'access arguments' => array('administer languages'),
     'file' => 'language.admin.inc',
@@ -49,7 +50,7 @@ function language_menu() {
   );
   $items['admin/config/regional/language/add'] = array(
     'title' => 'Add language',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('language_admin_add_form'),
     'access arguments' => array('administer languages'),
     'weight' => 5,
@@ -58,14 +59,14 @@ function language_menu() {
   );
   $items['admin/config/regional/language/edit/%language'] = array(
     'title' => 'Edit language',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('language_admin_edit_form', 5),
     'access arguments' => array('administer languages'),
     'file' => 'language.admin.inc',
   );
   $items['admin/config/regional/language/delete/%language'] = array(
     'title' => 'Confirm delete',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('language_admin_delete_form', 5),
     'access arguments' => array('administer languages'),
     'file' => 'language.admin.inc',
@@ -125,7 +126,7 @@ function language_save($language) {
 
   // If name was not set, we add a predefined language.
   if (!isset($language->name)) {
-    include_once DRUPAL_ROOT . '/core/includes/standard.inc';
+    include_once ROOT . '/core/includes/standard.inc';
     $predefined = standard_language_list();
     $language->name = $predefined[$language->langcode][0];
     $language->direction = isset($predefined[$language->langcode][2]) ? $predefined[$language->langcode][2] : LANGUAGE_LTR;
@@ -141,12 +142,12 @@ function language_save($language) {
   // Save the record and inform others about the change.
   $t_args = array('%language' => $language->name, '%langcode' => $language->langcode);
   if ($language->is_new) {
-    drupal_write_record('language', $language);
+    write_record('language', $language);
     module_invoke_all('language_insert', $language);
     watchdog('language', 'The %language (%langcode) language has been created.', $t_args);
   }
   else {
-    drupal_write_record('language', $language, array('langcode'));
+    write_record('language', $language, array('langcode'));
     module_invoke_all('language_update', $language);
     watchdog('language', 'The %language (%langcode) language has been updated.', $t_args);
   }
@@ -161,7 +162,7 @@ function language_save($language) {
   variable_set('language_count', db_query('SELECT COUNT(langcode) FROM {language} WHERE enabled = 1')->fetchField());
 
   // Kill the static cache in language_list().
-  drupal_static_reset('language_list');
+  drupal_static_reset('Drupal\language_list');
 
   return $language;
 }
@@ -190,7 +191,7 @@ function language_delete($langcode) {
       variable_set('language_count', variable_get('language_count', 1) - 1);
     }
 
-    drupal_static_reset('language_list');
+    drupal_static_reset('Drupal\language_list');
 
     $t_args = array('%language' => $language->name, '%langcode' => $language->langcode);
     watchdog('language', 'The %language (%langcode) language has been removed.', $t_args);
@@ -202,7 +203,7 @@ function language_delete($langcode) {
 /**
  * Implements hook_css_alter().
  *
- * This function checks all CSS files currently added via drupal_add_css() and
+ * This function checks all CSS files currently added via add_css() and
  * and checks to see if a related right to left CSS file should be included.
  */
 function language_css_alter(&$css) {
diff --git a/core/modules/language/language.test b/core/modules/language/language.test
index 0a59937..bdb7da7 100644
--- a/core/modules/language/language.test
+++ b/core/modules/language/language.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -12,7 +13,7 @@
 /**
  * Functional tests for the language list configuration forms.
  */
-class LanguageListTest extends DrupalWebTestCase {
+class LanguageListTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Language list configuration',
@@ -121,7 +122,7 @@ class LanguageListTest extends DrupalWebTestCase {
     $this->drupalGet('admin/config/regional/language/delete/' . $langcode);
     $this->assertResponse(404, t('Language no longer found.'));
     // Make sure the "language_count" variable has been updated correctly.
-    drupal_static_reset('language_list');
+    drupal_static_reset('Drupal\language_list');
     $enabled_languages = language_list(TRUE);
     $this->assertEqual(variable_get('language_count', 1), count($enabled_languages), t('Language count is correct.'));
     // Delete a disabled language.
@@ -132,7 +133,7 @@ class LanguageListTest extends DrupalWebTestCase {
     $this->drupalPost($path, $edit, t('Save configuration'));
     $this->assertNoFieldChecked('edit-languages-fr-enabled', t('French language disabled.'));
     // Get the count of enabled languages.
-    drupal_static_reset('language_list');
+    drupal_static_reset('Drupal\language_list');
     $enabled_languages = language_list(TRUE);
     // Delete the disabled language.
     $this->drupalPost('admin/config/regional/language/delete/fr', array(), t('Delete'));
diff --git a/core/modules/locale/locale.admin.inc b/core/modules/locale/locale.admin.inc
index c0a9137..f86c655 100644
--- a/core/modules/locale/locale.admin.inc
+++ b/core/modules/locale/locale.admin.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -9,7 +10,7 @@
  * Setting for language negotiation options
  */
 function locale_languages_configure_form() {
-  include_once DRUPAL_ROOT . '/core/includes/language.inc';
+  include_once ROOT . '/core/includes/language.inc';
 
   $form = array(
     '#submit' => array('locale_languages_configure_form_submit'),
@@ -172,14 +173,14 @@ function theme_locale_languages_configure_form($variables) {
       'attributes' => array('id' => "language-negotiation-providers-$type"),
     );
     $table  = theme('table', $variables);
-    $table .= drupal_render_children($form[$type]);
+    $table .= render_children($form[$type]);
 
-    drupal_add_tabledrag("language-negotiation-providers-$type", 'order', 'sibling', "language-provider-weight-$type");
+    add_tabledrag("language-negotiation-providers-$type", 'order', 'sibling', "language-provider-weight-$type");
 
     $output .= '<div class="form-item">' . $title . $description . $table . '</div>';
   }
 
-  $output .= drupal_render_children($form);
+  $output .= render_children($form);
   return $output;
 }
 
@@ -212,7 +213,7 @@ function locale_languages_configure_form_submit($form, &$form_state) {
   language_types_set();
 
   $form_state['redirect'] = 'admin/config/regional/language/configure';
-  drupal_set_message(t('Language negotiation configuration saved.'));
+  set_message(t('Language negotiation configuration saved.'));
 }
 
 /**
@@ -344,7 +345,7 @@ function locale_language_providers_url_form_submit($form, &$form_state) {
   locale_language_negotiation_url_prefixes_save($form_state['values']['prefix']);
   locale_language_negotiation_url_domains_save($form_state['values']['domain']);
 
-  drupal_set_message(t('Configuration saved.'));
+  set_message(t('Configuration saved.'));
 }
 
 /**
@@ -393,7 +394,7 @@ function theme_locale_date_format_form($variables) {
 
   $output = drupal_render($form['language']);
   $output .= theme('table', array('header' => $header, 'rows' => $rows));
-  $output .= drupal_render_children($form);
+  $output .= render_children($form);
 
   return $output;
 }
@@ -484,7 +485,7 @@ function locale_date_format_form($form, &$form_state, $langcode) {
  * Submit handler for configuring localized date formats on the locale_date_format_form.
  */
 function locale_date_format_form_submit($form, &$form_state) {
-  include_once DRUPAL_ROOT . '/core/includes/locale.inc';
+  include_once ROOT . '/core/includes/locale.inc';
   $langcode = $form_state['values']['langcode'];
 
   // Get list of date format types.
@@ -496,7 +497,7 @@ function locale_date_format_form_submit($form, &$form_state) {
     }
     locale_date_format_save($langcode, $type, $format);
   }
-  drupal_set_message(t('Configuration saved.'));
+  set_message(t('Configuration saved.'));
   $form_state['redirect'] = 'admin/config/regional/date-time/locale';
 }
 
diff --git a/core/modules/locale/locale.api.php b/core/modules/locale/locale.api.php
index 4b4523a..eb5d721 100644
--- a/core/modules/locale/locale.api.php
+++ b/core/modules/locale/locale.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -132,7 +133,7 @@ function hook_language_negotiation_info() {
         'switcher' => 'custom_language_switcher_callback',
         'url_rewrite' => 'custom_language_url_rewrite_callback',
       ),
-      'file' => drupal_get_path('module', 'custom') . '/custom.module',
+      'file' => get_path('module', 'custom') . '/custom.module',
       'weight' => -4,
       'types' => array('custom_language_type'),
       'name' => t('Custom language provider'),
diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc
index a4982e1..6e7fd07 100644
--- a/core/modules/locale/locale.bulk.inc
+++ b/core/modules/locale/locale.bulk.inc
@@ -1,17 +1,18 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
  * Mass import-export and batch import functionality for Gettext .po files.
  */
 
-include_once DRUPAL_ROOT . '/core/includes/gettext.inc';
+include_once ROOT . '/core/includes/gettext.inc';
 
 /**
  * User interface for the translation import screen.
  */
 function locale_translate_import_form($form, &$form_state) {
-  drupal_static_reset('language_list');
+  drupal_static_reset('Drupal\language_list');
   $languages = language_list(TRUE);
 
   // Initialize a language list to the ones available, including English if we
@@ -75,28 +76,28 @@ function locale_translate_import_form_submit($form, &$form_state) {
   if ($file = file_save_upload('file', $validators)) {
 
     // Add language, if not yet supported
-    drupal_static_reset('language_list');
+    drupal_static_reset('Drupal\language_list');
     $languages = language_list();
     $langcode = $form_state['values']['langcode'];
     if (!isset($languages[$langcode])) {
-      include_once DRUPAL_ROOT . '/core/includes/standard.inc';
+      include_once ROOT . '/core/includes/standard.inc';
       $predefined = standard_language_list();
       $language = (object) array(
         'langcode' => $langcode,
       );
       language_save($language);
-      drupal_set_message(t('The language %language has been created.', array('%language' => t($predefined[$langcode][0]))));
+      set_message(t('The language %language has been created.', array('%language' => t($predefined[$langcode][0]))));
     }
 
     // Now import strings into the language
     if ($return = _locale_import_po($file, $langcode, $form_state['values']['mode']) == FALSE) {
       $variables = array('%filename' => $file->filename);
-      drupal_set_message(t('The translation import of %filename failed.', $variables), 'error');
+      set_message(t('The translation import of %filename failed.', $variables), 'error');
       watchdog('locale', 'The translation import of %filename failed.', $variables, WATCHDOG_ERROR);
     }
   }
   else {
-    drupal_set_message(t('File to import not found.'), 'error');
+    set_message(t('File to import not found.'), 'error');
     $form_state['redirect'] = 'admin/config/regional/translate/import';
     return;
   }
@@ -110,7 +111,7 @@ function locale_translate_import_form_submit($form, &$form_state) {
  */
 function locale_translate_export_screen() {
   // Get all enabled languages, except English, if we should not translate that.
-  drupal_static_reset('language_list');
+  drupal_static_reset('Drupal\language_list');
   $languages = language_list(TRUE);
   $language_options = array();
   foreach ($languages as $langcode => $language) {
@@ -122,10 +123,10 @@ function locale_translate_export_screen() {
   $output = '';
   // Offer translation export if any language is set up.
   if (!empty($language_options)) {
-    $elements = drupal_get_form('locale_translate_export_po_form', $language_options);
+    $elements = get_form('locale_translate_export_po_form', $language_options);
     $output = drupal_render($elements);
   }
-  $elements = drupal_get_form('locale_translate_export_pot_form');
+  $elements = get_form('locale_translate_export_pot_form');
   $output .= drupal_render($elements);
   return $output;
 }
@@ -244,7 +245,7 @@ function locale_translate_batch_build($files, $finish_feedback = FALSE) {
       'title'         => $t('Importing interface translations'),
       'init_message'  => $t('Starting import'),
       'error_message' => $t('Error importing interface translations'),
-      'file'          => drupal_get_path('module', 'locale') . '/locale.bulk.inc',
+      'file'          => get_path('module', 'locale') . '/locale.bulk.inc',
     );
     if ($finish_feedback) {
       $batch['finished'] = 'locale_translate_batch_finished';
@@ -266,7 +267,7 @@ function locale_translate_batch_import($filepath, &$context) {
   // The filename is either {langcode}.po or {prefix}.{langcode}.po, so
   // we can extract the language code to use for the import from the end.
   if (preg_match('!(/|\.)([^\./]+)\.po$!', $filepath, $langcode)) {
-    $file = (object) array('filename' => drupal_basename($filepath), 'uri' => $filepath);
+    $file = (object) array('filename' => basename($filepath), 'uri' => $filepath);
     _locale_import_read_po('db-store', $file, LOCALE_IMPORT_KEEP, $langcode[2]);
     $context['results'][] = $filepath;
   }
@@ -277,6 +278,6 @@ function locale_translate_batch_import($filepath, &$context) {
  */
 function locale_translate_batch_finished($success, $results) {
   if ($success) {
-    drupal_set_message(format_plural(count($results), 'One translation file imported.', '@count translation files imported.'));
+    set_message(format_plural(count($results), 'One translation file imported.', '@count translation files imported.'));
   }
 }
diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install
index d2908c5..2c3670f 100644
--- a/core/modules/locale/locale.install
+++ b/core/modules/locale/locale.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -12,7 +13,7 @@
  * system on multilingual sites without needing any preliminary configuration.
  */
 function locale_install() {
-  require_once DRUPAL_ROOT . '/core/includes/language.inc';
+  require_once ROOT . '/core/includes/language.inc';
 
   // We cannot rely on language negotiation hooks here, because locale module is
   // not enabled yet. Therefore language_negotiation_set() cannot be used.
@@ -42,7 +43,7 @@ function locale_install() {
  * should run every time the module is enabled.
  */
 function locale_enable() {
-  require_once DRUPAL_ROOT . '/core/includes/locale.inc';
+  require_once ROOT . '/core/includes/locale.inc';
 
   $languages = language_list();
   $prefixes_old = locale_language_negotiation_url_prefixes();
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index 6b18988..91b6434 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -75,7 +76,7 @@ function locale_menu() {
   // Language negotiation.
   $items['admin/config/regional/language/configure'] = array(
     'title' => 'Detection and selection',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('locale_languages_configure_form'),
     'access arguments' => array('administer languages'),
     'weight' => 10,
@@ -84,7 +85,7 @@ function locale_menu() {
   );
   $items['admin/config/regional/language/configure/url'] = array(
     'title' => 'URL language detection configuration',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('locale_language_providers_url_form'),
     'access arguments' => array('administer languages'),
     'file' => 'locale.admin.inc',
@@ -92,7 +93,7 @@ function locale_menu() {
   );
   $items['admin/config/regional/language/configure/session'] = array(
     'title' => 'Session language detection configuration',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('locale_language_providers_session_form'),
     'access arguments' => array('administer languages'),
     'file' => 'locale.admin.inc',
@@ -115,7 +116,7 @@ function locale_menu() {
   );
   $items['admin/config/regional/translate/import'] = array(
     'title' => 'Import',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('locale_translate_import_form'),
     'access arguments' => array('translate interface'),
     'weight' => 20,
@@ -132,7 +133,7 @@ function locale_menu() {
   );
   $items['admin/config/regional/translate/edit/%'] = array(
     'title' => 'Edit string',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('locale_translate_edit_form', 5),
     'access arguments' => array('translate interface'),
     'file' => 'locale.pages.inc',
@@ -158,7 +159,7 @@ function locale_menu() {
   $items['admin/config/regional/date-time/locale/%/edit'] = array(
     'title' => 'Localize date formats',
     'description' => 'Configure date formats for each locale',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('locale_date_format_form', 5),
     'access arguments' => array('administer site configuration'),
     'file' => 'locale.admin.inc',
@@ -166,7 +167,7 @@ function locale_menu() {
   $items['admin/config/regional/date-time/locale/%/reset'] = array(
     'title' => 'Reset date formats',
     'description' => 'Reset localized date formats to global defaults',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('locale_date_format_reset_form', 5),
     'access arguments' => array('administer site configuration'),
     'file' => 'locale.admin.inc',
@@ -182,7 +183,7 @@ function locale_menu() {
  */
 function locale_init() {
   global $conf, $language;
-  include_once DRUPAL_ROOT . '/core/includes/locale.inc';
+  include_once ROOT . '/core/includes/locale.inc';
 
   // For each date type (e.g. long, short), get the localized date format
   // for the user's current language and override the default setting for it
@@ -406,7 +407,7 @@ function locale_field_language_fallback(&$display_language, $entity, $langcode)
     }
     elseif (!empty($entity->{$field_name})) {
       if (!isset($fallback_candidates)) {
-        require_once DRUPAL_ROOT . '/core/includes/language.inc';
+        require_once ROOT . '/core/includes/language.inc';
         $fallback_candidates = language_fallback_get_candidates();
       }
       foreach ($fallback_candidates as $fallback_language) {
@@ -440,7 +441,7 @@ function locale_entity_info_alter(&$entity_info) {
  *   detected. It is used by l() as the default language if none is specified.
  */
 function locale_language_types_info() {
-  require_once DRUPAL_ROOT . '/core/includes/locale.inc';
+  require_once ROOT . '/core/includes/locale.inc';
   return array(
     LANGUAGE_TYPE_INTERFACE => array(
       'name' => t('User interface text'),
@@ -461,7 +462,7 @@ function locale_language_types_info() {
  * Implements hook_language_negotiation_info().
  */
 function locale_language_negotiation_info() {
-  require_once DRUPAL_ROOT . '/core/includes/locale.inc';
+  require_once ROOT . '/core/includes/locale.inc';
   $file = '/core/includes/locale.inc';
   $providers = array();
 
@@ -534,7 +535,7 @@ function locale_language_negotiation_info() {
  * Implements hook_modules_enabled().
  */
 function locale_modules_enabled($modules) {
-  include_once DRUPAL_ROOT . '/core/includes/language.inc';
+  include_once ROOT . '/core/includes/language.inc';
   language_types_set();
   language_negotiation_purge();
 }
@@ -641,11 +642,11 @@ function locale($string = NULL, $context = NULL, $langcode = NULL) {
   global $language;
 
   // Use the advanced drupal_static() pattern, since this is called very often.
-  static $drupal_static_fast;
-  if (!isset($drupal_static_fast)) {
-    $drupal_static_fast['locale'] = &drupal_static(__FUNCTION__);
+  static $static_fast;
+  if (!isset($static_fast)) {
+    $static_fast['locale'] = &drupal_static(__FUNCTION__);
   }
-  $locale_t = &$drupal_static_fast['locale'];
+  $locale_t = &$static_fast['locale'];
 
 
   if (!isset($string)) {
@@ -729,7 +730,7 @@ function locale($string = NULL, $context = NULL, $langcode = NULL) {
  * Reset static variables used by locale().
  */
 function locale_reset() {
-  drupal_static_reset('locale');
+  drupal_static_reset('Drupal\locale');
 }
 
 /**
@@ -811,7 +812,7 @@ function locale_themes_enabled($themes) {
  *   identified projects for the components.
  */
 function locale_system_update($components) {
-  include_once drupal_get_path('module', 'locale') . '/locale.bulk.inc';
+  include_once get_path('module', 'locale') . '/locale.bulk.inc';
   if ($batch = locale_translate_batch_import_files(NULL, TRUE)) {
     batch_set($batch);
   }
@@ -820,7 +821,7 @@ function locale_system_update($components) {
 /**
  * Implements hook_js_alter().
  *
- * This function checks all JavaScript files currently added via drupal_add_js()
+ * This function checks all JavaScript files currently added via add_js()
  * and invokes parsing if they have not yet been parsed for Drupal.t()
  * and Drupal.formatPlural() calls. Also refreshes the JavaScript translation
  * file if necessary, and adds it to the page.
@@ -833,7 +834,7 @@ function locale_js_alter(&$javascript) {
   $files = $new_files = FALSE;
 
   // Require because locale_js_alter() could be called without locale_init().
-  require_once DRUPAL_ROOT . '/core/includes/locale.inc';
+  require_once ROOT . '/core/includes/locale.inc';
 
   foreach ($javascript as $item) {
     if ($item['type'] == 'file') {
@@ -878,7 +879,7 @@ function locale_js_alter(&$javascript) {
   if ($files && !empty($locale_javascripts[$language->langcode])) {
     // Add the translation JavaScript file to the page.
     $file = $dir . '/' . $language->langcode . '_' . $locale_javascripts[$language->langcode] . '.js';
-    $javascript[$file] = drupal_js_defaults($file);
+    $javascript[$file] = js_defaults($file);
   }
 }
 
@@ -890,7 +891,7 @@ function locale_js_alter(&$javascript) {
 function locale_library_info_alter(&$libraries, $module) {
   global $language;
   if ($module == 'system' && isset($libraries['system']['ui.datepicker'])) {
-    $datepicker = drupal_get_path('module', 'locale') . '/locale.datepicker.js';
+    $datepicker = get_path('module', 'locale') . '/locale.datepicker.js';
     $libraries['system']['ui.datepicker']['js'][$datepicker] = array('group' => JS_THEME);
     $libraries['system']['ui.datepicker']['js'][] = array(
       'data' => array(
@@ -911,14 +912,14 @@ function locale_library_info_alter(&$libraries, $module) {
  * Implements hook_block_info().
  */
 function locale_block_info() {
-  include_once DRUPAL_ROOT . '/core/includes/language.inc';
+  include_once ROOT . '/core/includes/language.inc';
   $block = array();
   $info = language_types_info();
   foreach (language_types_configurable(FALSE) as $type) {
     $block[$type] = array(
       'info' => t('Language switcher (@type)', array('@type' => $info[$type]['name'])),
       // Not worth caching.
-      'cache' => DRUPAL_NO_CACHE,
+      'cache' => NO_CACHE,
     );
   }
   return $block;
@@ -931,11 +932,11 @@ function locale_block_info() {
  */
 function locale_block_view($type) {
   if (language_multilingual()) {
-    $path = drupal_is_front_page() ? '<front>' : $_GET['q'];
+    $path = is_front_page() ? '<front>' : $_GET['q'];
     $links = language_negotiation_get_switch_links($type, $path);
 
     if (isset($links->links)) {
-      drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css');
+      add_css(get_path('module', 'locale') . '/locale.css');
       $class = "language-switcher-{$links->provider}";
       $variables = array('links' => $links->links, 'attributes' => array('class' => array($class)));
       $block['content'] = theme('links__locale_block', $variables);
@@ -962,15 +963,15 @@ function locale_preprocess_block(&$variables) {
 function locale_url_outbound_alter(&$path, &$options, $original_path) {
   // Only modify internal URLs.
   if (!$options['external'] && language_multilingual()) {
-    static $drupal_static_fast;
-    if (!isset($drupal_static_fast)) {
-      $drupal_static_fast['callbacks'] = &drupal_static(__FUNCTION__);
+    static $static_fast;
+    if (!isset($static_fast)) {
+      $static_fast['callbacks'] = &drupal_static(__FUNCTION__);
     }
-    $callbacks = &$drupal_static_fast['callbacks'];
+    $callbacks = &$static_fast['callbacks'];
 
     if (!isset($callbacks)) {
       $callbacks = array();
-      include_once DRUPAL_ROOT . '/core/includes/language.inc';
+      include_once ROOT . '/core/includes/language.inc';
 
       foreach (language_types_configurable() as $type) {
         // Get url rewriter callbacks only from enabled language providers.
@@ -978,7 +979,7 @@ function locale_url_outbound_alter(&$path, &$options, $original_path) {
 
         foreach ($negotiation as $id => $provider) {
           if (isset($provider['file'])) {
-            require_once DRUPAL_ROOT . '/' . $provider['file'];
+            require_once ROOT . '/' . $provider['file'];
           }
 
           // Avoid duplicate callback entries.
@@ -992,6 +993,7 @@ function locale_url_outbound_alter(&$path, &$options, $original_path) {
     }
 
     foreach ($callbacks as $callback) {
+      $callback = 'Drupal\\' . $callback;
       $callback($path, $options);
     }
 
@@ -1079,7 +1081,7 @@ function locale_form_language_admin_add_form_alter_submit($form, $form_state) {
     $langcode = $form_state['values']['predefined_langcode'];
   }
 
-  include_once drupal_get_path('module', 'locale') . '/locale.bulk.inc';
+  include_once get_path('module', 'locale') . '/locale.bulk.inc';
   locale_translate_add_language_set_batch($langcode);
 }
 
diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc
index e41bae5..bc4dcd4 100644
--- a/core/modules/locale/locale.pages.inc
+++ b/core/modules/locale/locale.pages.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -10,9 +11,9 @@
  */
 function locale_translate_seek_screen() {
   // Add CSS.
-  drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css');
+  add_css(get_path('module', 'locale') . '/locale.css');
 
-  $elements = drupal_get_form('locale_translation_filter_form');
+  $elements = get_form('locale_translation_filter_form');
   $output = drupal_render($elements);
   $output .= _locale_translate_seek();
   return $output;
@@ -95,8 +96,8 @@ function _locale_translate_seek() {
       array('data' => check_plain(truncate_utf8($string['source'], 150, FALSE, TRUE)) . '<br /><small>' . $string['location'] . '</small>'),
       $string['context'],
       array('data' => _locale_translate_language_list($string['languages'], $limit_language), 'align' => 'center'),
-      array('data' => l(t('edit'), "admin/config/regional/translate/edit/$lid", array('query' => drupal_get_destination())), 'class' => array('nowrap')),
-      array('data' => l(t('delete'), "admin/config/regional/translate/delete/$lid", array('query' => drupal_get_destination())), 'class' => array('nowrap')),
+      array('data' => l(t('edit'), "admin/config/regional/translate/edit/$lid", array('query' => get_destination())), 'class' => array('nowrap')),
+      array('data' => l(t('delete'), "admin/config/regional/translate/delete/$lid", array('query' => get_destination())), 'class' => array('nowrap')),
     );
   }
 
@@ -111,7 +112,7 @@ function _locale_translate_seek() {
  */
 function _locale_translate_language_list($translation, $limit_language) {
   // Add CSS.
-  drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css');
+  add_css(get_path('module', 'locale') . '/locale.css');
 
   $languages = language_list();
   if (!locale_translate_english()) {
@@ -151,7 +152,7 @@ function locale_translation_filters() {
   $filters = array();
 
   // Get all languages, except English
-  drupal_static_reset('language_list');
+  drupal_static_reset('Drupal\language_list');
   $languages = language_list(TRUE);
   $language_options = array();
   foreach ($languages as $langcode => $language) {
@@ -275,8 +276,8 @@ function locale_translate_edit_form($form, &$form_state, $lid) {
   // Fetch source string, if possible.
   $source = db_query('SELECT source, context, location FROM {locales_source} WHERE lid = :lid', array(':lid' => $lid))->fetchObject();
   if (!$source) {
-    drupal_set_message(t('String not found.'), 'error');
-    drupal_goto('admin/config/regional/translate/translate');
+    set_message(t('String not found.'), 'error');
+    redirect('admin/config/regional/translate/translate');
   }
 
   // Add original text to the top and some values for form altering.
@@ -384,7 +385,7 @@ function locale_translate_edit_form_submit($form, &$form_state) {
     _locale_invalidate_js($key);
   }
 
-  drupal_set_message(t('The string has been saved.'));
+  set_message(t('The string has been saved.'));
 
   // Clear locale cache.
   _locale_invalidate_js();
@@ -399,10 +400,10 @@ function locale_translate_edit_form_submit($form, &$form_state) {
  */
 function locale_translate_delete_page($lid) {
   if ($source = db_query('SELECT lid, source FROM {locales_source} WHERE lid = :lid', array(':lid' => $lid))->fetchObject()) {
-    return drupal_get_form('locale_translate_delete_form', $source);
+    return get_form('locale_translate_delete_form', $source);
   }
   else {
-    return drupal_not_found();
+    return not_found();
   }
 }
 
@@ -429,6 +430,6 @@ function locale_translate_delete_form_submit($form, &$form_state) {
   // Force JavaScript translation file recreation for all languages.
   _locale_invalidate_js();
   cache()->deletePrefix('locale:');
-  drupal_set_message(t('The string has been removed.'));
+  set_message(t('The string has been removed.'));
   $form_state['redirect'] = 'admin/config/regional/translate/translate';
 }
diff --git a/core/modules/locale/locale.test b/core/modules/locale/locale.test
index f102d4b..efaccc8 100644
--- a/core/modules/locale/locale.test
+++ b/core/modules/locale/locale.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use ReflectionFunction;
 
 /**
  * @file
@@ -24,7 +26,7 @@
 /**
  * Functional tests for language configuration's effect on negotiation setup.
  */
-class LocaleConfigurationTest extends DrupalWebTestCase {
+class LocaleConfigurationTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Language negotiation autoconfiguration',
@@ -90,7 +92,7 @@ class LocaleConfigurationTest extends DrupalWebTestCase {
 /**
  * Functional tests for JavaScript parsing for translatable strings.
  */
-class LocaleJavascriptTranslationTest extends DrupalWebTestCase {
+class LocaleJavascriptTranslationTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Javascript translation',
@@ -105,7 +107,7 @@ class LocaleJavascriptTranslationTest extends DrupalWebTestCase {
 
   function testFileParsing() {
 
-    $filename = drupal_get_path('module', 'locale_test') . '/locale_test.js';
+    $filename = get_path('module', 'locale_test') . '/locale_test.js';
 
     // Parse the file to look for source strings.
     _locale_parse_js_file($filename);
@@ -179,7 +181,7 @@ class LocaleJavascriptTranslationTest extends DrupalWebTestCase {
 /**
  * Functional test for string translation and validation.
  */
-class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
+class LocaleTranslationFunctionalTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'String translate, search and validate',
@@ -356,7 +358,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
       'direction' => '0',
     );
     $this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
-    drupal_static_reset('language_list');
+    drupal_static_reset('Drupal\language_list');
 
     // Build the JavaScript translation file.
     $this->drupalGet('admin/config/regional/translate/translate');
@@ -371,7 +373,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
     $this->drupalPost($url, $edit, t('Save translations'));
 
     // Trigger JavaScript translation parsing and building.
-    require_once DRUPAL_ROOT . '/core/includes/locale.inc';
+    require_once ROOT . '/core/includes/locale.inc';
     _locale_rebuild_js($langcode);
 
     $locale_javascripts = variable_get('locale_translation_javascript', array());
@@ -588,7 +590,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
 /**
  * Functional tests for the import of translation files.
  */
-class LocaleImportFunctionalTest extends DrupalWebTestCase {
+class LocaleImportFunctionalTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Translation import',
@@ -606,7 +608,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
     parent::setUp('locale', 'locale_test');
 
     // Set the translation file directory.
-    variable_set('locale_translate_file_directory', drupal_get_path('module', 'locale_test'));
+    variable_set('locale_translate_file_directory', get_path('module', 'locale_test'));
 
     $this->admin_user = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages'));
     $this->drupalLogin($this->admin_user);
@@ -953,7 +955,7 @@ EOF;
 /**
  * Functional tests for the export of translation files.
  */
-class LocaleExportFunctionalTest extends DrupalWebTestCase {
+class LocaleExportFunctionalTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Translation export',
@@ -1035,7 +1037,7 @@ EOF;
 /**
  * Tests for the st() function.
  */
-class LocaleInstallTest extends DrupalWebTestCase {
+class LocaleInstallTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'String translation using st()',
@@ -1048,15 +1050,15 @@ class LocaleInstallTest extends DrupalWebTestCase {
     parent::setUp('locale');
 
     // st() lives in install.inc, so ensure that it is loaded for all tests.
-    require_once DRUPAL_ROOT . '/core/includes/install.inc';
+    require_once ROOT . '/core/includes/install.inc';
   }
 
   /**
    * Verify that function signatures of t() and st() are equal.
    */
   function testFunctionSignatures() {
-    $reflector_t = new ReflectionFunction('t');
-    $reflector_st = new ReflectionFunction('st');
+    $reflector_t = new ReflectionFunction('Drupal\t');
+    $reflector_st = new ReflectionFunction('Drupal\st');
     $this->assertEqual($reflector_t->getParameters(), $reflector_st->getParameters(), t('Function signatures of t() and st() are equal.'));
   }
 }
@@ -1064,7 +1066,7 @@ class LocaleInstallTest extends DrupalWebTestCase {
 /**
  * Locale uninstall with English UI functional test.
  */
-class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
+class LocaleUninstallFunctionalTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Locale uninstall (EN)',
@@ -1090,7 +1092,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
     $locale_module = array('locale', 'language');
 
     // Add a new language and optionally set it as default.
-    require_once DRUPAL_ROOT . '/core/includes/locale.inc';
+    require_once ROOT . '/core/includes/locale.inc';
 
     $language = (object) array(
       'langcode' => 'fr',
@@ -1100,7 +1102,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
     language_save($language);
 
     // Check the UI language.
-    drupal_language_initialize();
+    language_initialize();
     $this->assertEqual($GLOBALS['language']->langcode, $this->langcode, t('Current language: %lang', array('%lang' => $GLOBALS['language']->langcode)));
 
     // Enable multilingual workflow option for articles.
@@ -1127,8 +1129,8 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
     variable_set('locale_cache_strings', 0);
 
     // Change language negotiation options.
-    drupal_load('module', 'locale');
-    variable_set('language_types', drupal_language_types() + array('language_custom' => TRUE));
+    load('module', 'locale');
+    variable_set('language_types', _language_types() + array('language_custom' => TRUE));
     variable_set('language_negotiation_' . LANGUAGE_TYPE_INTERFACE, locale_language_negotiation_info());
     variable_set('language_negotiation_' . LANGUAGE_TYPE_CONTENT, locale_language_negotiation_info());
     variable_set('language_negotiation_' . LANGUAGE_TYPE_URL, locale_language_negotiation_info());
@@ -1139,13 +1141,13 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
 
     // Uninstall Locale.
     module_disable($locale_module);
-    drupal_uninstall_modules($locale_module);
+    uninstall_modules($locale_module);
 
     // Visit the front page.
     $this->drupalGet('');
 
     // Check the init language logic.
-    drupal_language_initialize();
+    language_initialize();
     $this->assertEqual($GLOBALS['language']->langcode, 'en', t('Language after uninstall: %lang', array('%lang' => $GLOBALS['language']->langcode)));
 
     // Check JavaScript files deletion.
@@ -1156,8 +1158,8 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
     $this->assertEqual($language_count, 1, t('Language count: %count', array('%count' => $language_count)));
 
     // Check language negotiation.
-    require_once DRUPAL_ROOT . '/core/includes/language.inc';
-    $this->assertTrue(count(language_types()) == count(drupal_language_types()), t('Language types reset'));
+    require_once ROOT . '/core/includes/language.inc';
+    $this->assertTrue(count(language_types()) == count(_language_types()), t('Language types reset'));
     $language_negotiation = language_negotiation_get(LANGUAGE_TYPE_INTERFACE) == LANGUAGE_NEGOTIATION_DEFAULT;
     $this->assertTrue($language_negotiation, t('Interface language negotiation: %setting', array('%setting' => t($language_negotiation ? 'none' : 'set'))));
     $language_negotiation = language_negotiation_get(LANGUAGE_TYPE_CONTENT) == LANGUAGE_NEGOTIATION_DEFAULT;
@@ -1214,7 +1216,7 @@ class LocaleUninstallFrenchFunctionalTest extends LocaleUninstallFunctionalTest
 /**
  * Functional tests for the language switching feature.
  */
-class LocaleLanguageSwitchingFunctionalTest extends DrupalWebTestCase {
+class LocaleLanguageSwitchingFunctionalTest extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1292,7 +1294,7 @@ class LocaleLanguageSwitchingFunctionalTest extends DrupalWebTestCase {
 /**
  * Test browser language detection.
  */
-class LocaleBrowserDetectionTest extends DrupalUnitTestCase {
+class LocaleBrowserDetectionTest extends UnitTestCase {
 
   public static function getInfo() {
     return array(
@@ -1307,7 +1309,7 @@ class LocaleBrowserDetectionTest extends DrupalUnitTestCase {
    */
   function testLanguageFromBrowser() {
     // Load the required functions.
-    require_once DRUPAL_ROOT . '/core/includes/locale.inc';
+    require_once ROOT . '/core/includes/locale.inc';
 
     $languages = array(
       // In our test case, 'en' has priority over 'en-US'.
@@ -1411,7 +1413,7 @@ class LocaleBrowserDetectionTest extends DrupalUnitTestCase {
 /**
  * Functional tests for a user's ability to change their default language.
  */
-class LocaleUserLanguageFunctionalTest extends DrupalWebTestCase {
+class LocaleUserLanguageFunctionalTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'User language settings',
@@ -1496,7 +1498,7 @@ class LocaleUserLanguageFunctionalTest extends DrupalWebTestCase {
 /**
  * Functional test for language handling during user creation.
  */
-class LocaleUserCreationTest extends DrupalWebTestCase {
+class LocaleUserCreationTest extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1598,7 +1600,7 @@ class LocaleUserCreationTest extends DrupalWebTestCase {
 /**
  * Functional tests for configuring a different path alias per language.
  */
-class LocalePathFunctionalTest extends DrupalWebTestCase {
+class LocalePathFunctionalTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Path language settings',
@@ -1685,10 +1687,10 @@ class LocalePathFunctionalTest extends DrupalWebTestCase {
       'langcode' => LANGUAGE_NONE,
     );
     path_save($edit);
-    $lookup_path = drupal_lookup_path('alias', 'node/' . $node->nid, 'en');
+    $lookup_path = lookup_path('alias', 'node/' . $node->nid, 'en');
     $this->assertEqual($english_path, $lookup_path, t('English language alias has priority.'));
     // Same check for language 'xx'.
-    $lookup_path = drupal_lookup_path('alias', 'node/' . $node->nid, $prefix);
+    $lookup_path = lookup_path('alias', 'node/' . $node->nid, $prefix);
     $this->assertEqual($custom_language_path, $lookup_path, t('Custom language alias has priority.'));
     path_delete($edit);
 
@@ -1734,7 +1736,7 @@ class LocalePathFunctionalTest extends DrupalWebTestCase {
 /**
  * Functional tests for multilingual support on nodes.
  */
-class LocaleContentFunctionalTest extends DrupalWebTestCase {
+class LocaleContentFunctionalTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Content language settings',
@@ -1976,7 +1978,7 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase {
  *        http://example.cn/admin/config
  *          UI language in Chinese
  */
-class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
+class LocaleUILanguageNegotiationTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'UI language negotiation',
@@ -1987,8 +1989,8 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
 
   function setUp() {
     parent::setUp('locale', 'locale_test');
-    require_once DRUPAL_ROOT . '/core/includes/language.inc';
-    drupal_load('module', 'locale');
+    require_once ROOT . '/core/includes/language.inc';
+    load('module', 'locale');
     $admin_user = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages', 'administer blocks'));
     $this->drupalLogin($admin_user);
   }
@@ -2013,7 +2015,7 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
     $language_domain = 'example.cn';
 
     // Setup the site languages by installing two languages.
-    require_once DRUPAL_ROOT . '/core/includes/locale.inc';
+    require_once ROOT . '/core/includes/locale.inc';
     $language = (object) array(
       'langcode' => $langcode_browser_fallback,
     );
@@ -2031,7 +2033,7 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
     // into database when seen by t(). Without doing this, our target string
     // is for some reason not found when doing translate search. This might
     // be some bug.
-    drupal_static_reset('language_list');
+    drupal_static_reset('Drupal\language_list');
     $languages = language_list(TRUE);
     variable_set('language_default', $languages['vi']);
     // First visit this page to make sure our target string is searchable.
@@ -2217,7 +2219,7 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
 /**
  * Test that URL rewriting works as expected.
  */
-class LocaleUrlRewritingTest extends DrupalWebTestCase {
+class LocaleUrlRewritingTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'URL rewriting',
@@ -2252,9 +2254,9 @@ class LocaleUrlRewritingTest extends DrupalWebTestCase {
     $this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
 
     // Reset static caching.
-    drupal_static_reset('language_list');
-    drupal_static_reset('locale_url_outbound_alter');
-    drupal_static_reset('locale_language_url_rewrite_url');
+    drupal_static_reset('Drupal\language_list');
+    drupal_static_reset('Drupal\locale_url_outbound_alter');
+    drupal_static_reset('Drupal\locale_language_url_rewrite_url');
   }
 
   /**
@@ -2302,7 +2304,7 @@ class LocaleUrlRewritingTest extends DrupalWebTestCase {
 /**
  * Functional test for multilingual fields.
  */
-class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase {
+class LocaleMultilingualFieldsFunctionalTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Multilingual fields',
@@ -2318,7 +2320,7 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase {
     $this->drupalLogin($admin_user);
 
     // Add a new language.
-    require_once DRUPAL_ROOT . '/core/includes/locale.inc';
+    require_once ROOT . '/core/includes/locale.inc';
     $language = (object) array(
       'langcode' => 'it',
       'name' => 'Italian',
@@ -2423,7 +2425,7 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase {
 /**
  * Functional tests for comment language.
  */
-class LocaleCommentLanguageFunctionalTest extends DrupalWebTestCase {
+class LocaleCommentLanguageFunctionalTest extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -2472,7 +2474,7 @@ class LocaleCommentLanguageFunctionalTest extends DrupalWebTestCase {
    * Test that comment language is properly set.
    */
   function testCommentLanguage() {
-    drupal_static_reset('language_list');
+    drupal_static_reset('Drupal\language_list');
 
     // Create two nodes, one for english and one for french, and comment each
     // node using both english and french as content language by changing URL
@@ -2517,7 +2519,7 @@ class LocaleCommentLanguageFunctionalTest extends DrupalWebTestCase {
 /**
  * Functional tests for localizing date formats.
  */
-class LocaleDateFormatsFunctionalTest extends DrupalWebTestCase {
+class LocaleDateFormatsFunctionalTest extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -2586,7 +2588,7 @@ class LocaleDateFormatsFunctionalTest extends DrupalWebTestCase {
 /**
  * Functional test for language types/negotiation info.
  */
-class LocaleLanguageNegotiationInfoFunctionalTest extends DrupalWebTestCase {
+class LocaleLanguageNegotiationInfoFunctionalTest extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -2598,7 +2600,7 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends DrupalWebTestCase {
 
   function setUp() {
     parent::setUp('locale');
-    require_once DRUPAL_ROOT .'/core/includes/language.inc';
+    require_once ROOT .'/core/includes/language.inc';
     $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'view the administration theme'));
     $this->drupalLogin($admin_user);
     $this->drupalPost('admin/config/regional/language/add', array('predefined_langcode' => 'it'), t('Add language'));
@@ -2622,7 +2624,7 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends DrupalWebTestCase {
     variable_set('locale_test_content_language_type', TRUE);
     $this->languageNegotiationUpdate();
     $type = LANGUAGE_TYPE_CONTENT;
-    $language_types = variable_get('language_types', drupal_language_types());
+    $language_types = variable_get('language_types', _language_types());
     $this->assertTrue($language_types[$type], t('Content language type is configurable.'));
 
     // Enable some core and custom language providers. The test language type is
@@ -2703,15 +2705,15 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends DrupalWebTestCase {
 
     // Enable/disable locale_test only if we did not already before.
     if ($last_op != $op) {
-      $function = "module_{$op}";
+      $function = 'Drupal\module_' . $op;
       $function($modules);
       // Reset hook implementation cache.
       module_implements_reset();
     }
 
-    drupal_static_reset('language_types_info');
-    drupal_static_reset('language_negotiation_info');
-    $function = "locale_modules_{$op}d";
+    drupal_static_reset('Drupal\language_types_info');
+    drupal_static_reset('Drupal\language_negotiation_info');
+    $function = 'Drupal\locale_modules_' . $op . 'd';
     if (function_exists($function)) {
       $function($modules);
     }
@@ -2723,7 +2725,7 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends DrupalWebTestCase {
    * Check that language negotiation for fixed types matches the stored one.
    */
   protected function checkFixedLanguageTypes() {
-    drupal_static_reset('language_types_info');
+    drupal_static_reset('Drupal\language_types_info');
     foreach (language_types_info() as $type => $info) {
       if (isset($info['fixed'])) {
         $negotiation = variable_get("language_negotiation_$type", array());
diff --git a/core/modules/locale/tests/locale_test.module b/core/modules/locale/tests/locale_test.module
index 868e0ef..44a2981 100644
--- a/core/modules/locale/tests/locale_test.module
+++ b/core/modules/locale/tests/locale_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -23,7 +24,7 @@ function locale_test_boot() {
 function locale_test_init() {
   locale_test_store_language_negotiation();
   if (isset($GLOBALS['language']) && isset($GLOBALS['language']->provider)) {
-    drupal_set_message(t('Language negotiation provider: @name', array('@name' => $GLOBALS['language']->provider)));
+    set_message(t('Language negotiation provider: @name', array('@name' => $GLOBALS['language']->provider)));
   }
 }
 
@@ -62,7 +63,7 @@ function locale_test_language_negotiation_info() {
       'callbacks' => array(
         'language' => 'locale_test_language_provider',
       ),
-      'file' => drupal_get_path('module', 'locale_test') .'/locale_test.module',
+      'file' => get_path('module', 'locale_test') .'/locale_test.module',
       'weight' => -10,
       'description' => t('This is a test language provider.'),
     );
diff --git a/core/modules/menu/menu.admin.inc b/core/modules/menu/menu.admin.inc
index f933feb..c2d0e5d 100644
--- a/core/modules/menu/menu.admin.inc
+++ b/core/modules/menu/menu.admin.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use PDO;
 
 /**
  * @file
@@ -48,7 +50,7 @@ function theme_menu_admin_overview($variables) {
  */
 function menu_overview_form($form, &$form_state, $menu) {
   global $menu_admin;
-  $form['#attached']['css'] = array(drupal_get_path('module', 'menu') . '/menu.css');
+  $form['#attached']['css'] = array(get_path('module', 'menu') . '/menu.css');
   $sql = "
     SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.delivery_callback, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
     FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path
@@ -186,7 +188,7 @@ function menu_overview_form_submit($form, &$form_state) {
     $item['customized'] = 1;
     menu_link_save($item);
   }
-  drupal_set_message(t('Your configuration has been saved.'));
+  set_message(t('Your configuration has been saved.'));
 }
 
 /**
@@ -201,8 +203,8 @@ function menu_overview_form_submit($form, &$form_state) {
 function theme_menu_overview_form($variables) {
   $form = $variables['form'];
 
-  drupal_add_tabledrag('menu-overview', 'match', 'parent', 'menu-plid', 'menu-plid', 'menu-mlid', TRUE, MENU_MAX_DEPTH - 1);
-  drupal_add_tabledrag('menu-overview', 'order', 'sibling', 'menu-weight');
+  add_tabledrag('menu-overview', 'match', 'parent', 'menu-plid', 'menu-plid', 'menu-mlid', TRUE, MENU_MAX_DEPTH - 1);
+  add_tabledrag('menu-overview', 'order', 'sibling', 'menu-weight');
 
   $header = array(
     t('Menu link'),
@@ -248,7 +250,7 @@ function theme_menu_overview_form($variables) {
     $rows[] = array(array('data' => $form['#empty_text'], 'colspan' => '7'));
   }
   $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'menu-overview')));
-  $output .= drupal_render_children($form);
+  $output .= render_children($form);
   return $output;
 }
 
@@ -357,15 +359,15 @@ function menu_edit_item($form, &$form_state, $type, $item, $menu) {
  */
 function menu_edit_item_validate($form, &$form_state) {
   $item = &$form_state['values'];
-  $normal_path = drupal_get_normal_path($item['link_path']);
+  $normal_path = get_normal_path($item['link_path']);
   if ($item['link_path'] != $normal_path) {
-    drupal_set_message(t('The menu system stores system paths only, but will use the URL alias for display. %link_path has been stored as %normal_path', array('%link_path' => $item['link_path'], '%normal_path' => $normal_path)));
+    set_message(t('The menu system stores system paths only, but will use the URL alias for display. %link_path has been stored as %normal_path', array('%link_path' => $item['link_path'], '%normal_path' => $normal_path)));
     $item['link_path'] = $normal_path;
   }
   if (!url_is_external($item['link_path'])) {
     $parsed_link = parse_url($item['link_path']);
     if (isset($parsed_link['query'])) {
-      $item['options']['query'] = drupal_get_query_array($parsed_link['query']);
+      $item['options']['query'] = get_query_array($parsed_link['query']);
     }
     else {
       // Use unset() rather than setting to empty string
@@ -382,7 +384,7 @@ function menu_edit_item_validate($form, &$form_state) {
       $item['link_path'] = $parsed_link['path'];
     }
   }
-  if (!trim($item['link_path']) || !drupal_valid_path($item['link_path'], TRUE)) {
+  if (!trim($item['link_path']) || !valid_path($item['link_path'], TRUE)) {
     form_set_error('link_path', t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $item['link_path'])));
   }
 }
@@ -408,10 +410,10 @@ function menu_edit_item_submit($form, &$form_state) {
   $item['options']['attributes']['title'] = $item['description'];
   list($item['menu_name'], $item['plid']) = explode(':', $item['parent']);
   if (!menu_link_save($item)) {
-    drupal_set_message(t('There was an error saving the menu link.'), 'error');
+    set_message(t('There was an error saving the menu link.'), 'error');
   }
   else {
-    drupal_set_message(t('Your configuration has been saved.'));
+    set_message(t('Your configuration has been saved.'));
   }
   $form_state['redirect'] = 'admin/structure/menu/manage/' . $item['menu_name'];
 }
@@ -496,10 +498,10 @@ function menu_delete_menu_page($menu) {
   // System-defined menus may not be deleted.
   $system_menus = menu_list_system_menus();
   if (isset($system_menus[$menu['menu_name']])) {
-    drupal_access_denied();
+    access_denied();
     return;
   }
-  return drupal_get_form('menu_delete_menu_confirm', $menu);
+  return get_form('menu_delete_menu_confirm', $menu);
 }
 
 /**
@@ -545,7 +547,7 @@ function menu_delete_menu_confirm_submit($form, &$form_state) {
   menu_delete($menu);
 
   $t_args = array('%title' => $menu['title']);
-  drupal_set_message(t('The custom menu %title has been deleted.', $t_args));
+  set_message(t('The custom menu %title has been deleted.', $t_args));
   watchdog('menu', 'Deleted custom menu %title and all its menu links.', $t_args, WATCHDOG_NOTICE);
 }
 
@@ -595,7 +597,7 @@ function menu_edit_menu_submit($form, &$form_state) {
       menu_link_save($link);
     }
   }
-  drupal_set_message(t('Your configuration has been saved.'));
+  set_message(t('Your configuration has been saved.'));
   $form_state['redirect'] = $path . $menu['menu_name'];
 }
 
@@ -606,10 +608,10 @@ function menu_item_delete_page($item) {
   // Links defined via hook_menu may not be deleted. Updated items are an
   // exception, as they can be broken.
   if ($item['module'] == 'system' && !$item['updated']) {
-    drupal_access_denied();
+    access_denied();
     return;
   }
-  return drupal_get_form('menu_item_delete_form', $item);
+  return get_form('menu_item_delete_form', $item);
 }
 
 /**
@@ -627,7 +629,7 @@ function menu_item_delete_form_submit($form, &$form_state) {
   $item = $form['#item'];
   menu_link_delete($item['mlid']);
   $t_args = array('%title' => $item['link_title']);
-  drupal_set_message(t('The menu link %title has been deleted.', $t_args));
+  set_message(t('The menu link %title has been deleted.', $t_args));
   watchdog('menu', 'Deleted menu link %title.', $t_args, WATCHDOG_NOTICE);
   $form_state['redirect'] = 'admin/structure/menu/manage/' . $item['menu_name'];
 }
@@ -646,7 +648,7 @@ function menu_reset_item_confirm($form, &$form_state, $item) {
 function menu_reset_item_confirm_submit($form, &$form_state) {
   $item = $form_state['values']['item'];
   $new_item = menu_reset_item($item);
-  drupal_set_message(t('The menu link was reset to its default settings.'));
+  set_message(t('The menu link was reset to its default settings.'));
   $form_state['redirect'] = 'admin/structure/menu/manage/' . $new_item['menu_name'];
 }
 
diff --git a/core/modules/menu/menu.api.php b/core/modules/menu/menu.api.php
index 3f3818e..6c541ad 100644
--- a/core/modules/menu/menu.api.php
+++ b/core/modules/menu/menu.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/menu/menu.install b/core/modules/menu/menu.install
index 05aed28..3419181 100644
--- a/core/modules/menu/menu.install
+++ b/core/modules/menu/menu.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module
index 93d767d..351f83d 100644
--- a/core/modules/menu/menu.module
+++ b/core/modules/menu/menu.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use PDO;
 
 /**
  * @file
@@ -78,7 +80,7 @@ function menu_menu() {
   );
   $items['admin/structure/menu/add'] = array(
     'title' => 'Add menu',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('menu_edit_menu', 'add'),
     'access arguments' => array('administer menu'),
     'type' => MENU_LOCAL_ACTION,
@@ -86,7 +88,7 @@ function menu_menu() {
   );
   $items['admin/structure/menu/settings'] = array(
     'title' => 'Settings',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('menu_configure'),
     'access arguments' => array('administer menu'),
     'type' => MENU_LOCAL_TASK,
@@ -95,7 +97,7 @@ function menu_menu() {
   );
   $items['admin/structure/menu/manage/%menu'] = array(
     'title' => 'Customize menu',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('menu_overview_form', 4),
     'title callback' => 'menu_overview_title',
     'title arguments' => array(4),
@@ -110,7 +112,7 @@ function menu_menu() {
   );
   $items['admin/structure/menu/manage/%menu/add'] = array(
     'title' => 'Add link',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('menu_edit_item', 'add', NULL, 4),
     'access arguments' => array('administer menu'),
     'type' => MENU_LOCAL_ACTION,
@@ -118,7 +120,7 @@ function menu_menu() {
   );
   $items['admin/structure/menu/manage/%menu/edit'] = array(
     'title' => 'Edit menu',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('menu_edit_menu', 'edit', 4),
     'access arguments' => array('administer menu'),
     'type' => MENU_LOCAL_TASK,
@@ -134,14 +136,14 @@ function menu_menu() {
   );
   $items['admin/structure/menu/item/%menu_link/edit'] = array(
     'title' => 'Edit menu link',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('menu_edit_item', 'edit', 4, NULL),
     'access arguments' => array('administer menu'),
     'file' => 'menu.admin.inc',
   );
   $items['admin/structure/menu/item/%menu_link/reset'] = array(
     'title' => 'Reset menu link',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('menu_reset_item_confirm', 4),
     'access arguments' => array('administer menu'),
     'file' => 'menu.admin.inc',
@@ -394,7 +396,7 @@ function menu_parent_options_js() {
   }
   $options = _menu_get_options(menu_get_menus(), $available_menus, array('mlid' => 0));
 
-  drupal_json_output($options);
+  json_output($options);
 }
 
 /**
@@ -474,7 +476,7 @@ function menu_block_info() {
     $blocks[$name]['info'] = check_plain($title);
     // Menu blocks can't be cached because each menu item can have
     // a custom access callback. menu.inc manages its own caching.
-    $blocks[$name]['cache'] = DRUPAL_NO_CACHE;
+    $blocks[$name]['cache'] = NO_CACHE;
   }
   return $blocks;
 }
@@ -543,7 +545,7 @@ function menu_node_save($node) {
         unset($link['options']['attributes']['title']);
       }
       if (!menu_link_save($link)) {
-        drupal_set_message(t('There was an error saving the menu link.'), 'error');
+        set_message(t('There was an error saving the menu link.'), 'error');
       }
     }
   }
@@ -646,7 +648,7 @@ function menu_form_node_form_alter(&$form, $form_state) {
     '#collapsed' => !$link['link_title'],
     '#group' => 'additional_settings',
     '#attached' => array(
-      'js' => array(drupal_get_path('module', 'menu') . '/menu.js'),
+      'js' => array(get_path('module', 'menu') . '/menu.js'),
     ),
     '#tree' => TRUE,
     '#weight' => -2,
@@ -738,7 +740,7 @@ function menu_form_node_type_form_alter(&$form, $form_state) {
     '#collapsible' => TRUE,
     '#collapsed' => TRUE,
     '#attached' => array(
-      'js' => array(drupal_get_path('module', 'menu') . '/menu.admin.js'),
+      'js' => array(get_path('module', 'menu') . '/menu.admin.js'),
     ),
     '#group' => 'additional_settings',
   );
@@ -765,7 +767,7 @@ function menu_form_node_type_form_alter(&$form, $form_state) {
 
   // Call Drupal.menu_update_parent_list() to filter the list of
   // available default parent menu items based on the selected menus.
-  drupal_add_js(
+  add_js(
     '(function ($) { Drupal.menu_update_parent_list(); })(jQuery);',
     array('scope' => 'footer', 'type' => 'inline')
   );
diff --git a/core/modules/menu/menu.test b/core/modules/menu/menu.test
index 5fa27c7..80efd8c 100644
--- a/core/modules/menu/menu.test
+++ b/core/modules/menu/menu.test
@@ -1,11 +1,12 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
  * Tests for menu.module.
  */
 
-class MenuTestCase extends DrupalWebTestCase {
+class MenuTestCase extends WebTestCase {
   protected $big_user;
   protected $std_user;
   protected $menu;
@@ -581,7 +582,7 @@ class MenuTestCase extends DrupalWebTestCase {
 /**
  * Test menu settings for nodes.
  */
-class MenuNodeTestCase extends DrupalWebTestCase {
+class MenuNodeTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Menu settings for nodes',
diff --git a/core/modules/node/content_types.inc b/core/modules/node/content_types.inc
index c76a5e2..952ee2a 100644
--- a/core/modules/node/content_types.inc
+++ b/core/modules/node/content_types.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -130,7 +132,7 @@ function node_type_form($form, &$form_state, $type = NULL) {
   $form['additional_settings'] = array(
     '#type' => 'vertical_tabs',
     '#attached' => array(
-      'js' => array(drupal_get_path('module', 'node') . '/content_types.js'),
+      'js' => array(get_path('module', 'node') . '/content_types.js'),
     ),
   );
 
@@ -156,11 +158,11 @@ function node_type_form($form, &$form_state, $type = NULL) {
   $form['submission']['node_preview'] = array(
     '#type' => 'radios',
     '#title' => t('Preview before submitting'),
-    '#default_value' => variable_get('node_preview_' . $type->type, DRUPAL_OPTIONAL),
+    '#default_value' => variable_get('node_preview_' . $type->type, OPTIONAL),
     '#options' => array(
-      DRUPAL_DISABLED => t('Disabled'),
-      DRUPAL_OPTIONAL => t('Optional'),
-      DRUPAL_REQUIRED => t('Required'),
+      DISABLED => t('Disabled'),
+      OPTIONAL => t('Optional'),
+      REQUIRED => t('Required'),
     ),
   );
   $form['submission']['help']  = array(
@@ -353,11 +355,11 @@ function node_type_form_submit($form, &$form_state) {
   $t_args = array('%name' => $type->name);
 
   if ($status == SAVED_UPDATED) {
-    drupal_set_message(t('The content type %name has been updated.', $t_args));
+    set_message(t('The content type %name has been updated.', $t_args));
   }
   elseif ($status == SAVED_NEW) {
     node_add_body_field($type);
-    drupal_set_message(t('The content type %name has been added.', $t_args));
+    set_message(t('The content type %name has been added.', $t_args));
     watchdog('node', 'Added content type %name.', $t_args, WATCHDOG_NOTICE, l(t('view'), 'admin/structure/types'));
   }
 
@@ -373,7 +375,7 @@ function node_node_type_insert($info) {
     $update_count = node_type_update_nodes($info->old_type, $info->type);
 
     if ($update_count) {
-      drupal_set_message(format_plural($update_count, 'Changed the content type of 1 post from %old-type to %type.', 'Changed the content type of @count posts from %old-type to %type.', array('%old-type' => $info->old_type, '%type' => $info->type)));
+      set_message(format_plural($update_count, 'Changed the content type of 1 post from %old-type to %type.', 'Changed the content type of @count posts from %old-type to %type.', array('%old-type' => $info->old_type, '%type' => $info->type)));
     }
   }
 }
@@ -386,7 +388,7 @@ function node_node_type_update($info) {
     $update_count = node_type_update_nodes($info->old_type, $info->type);
 
     if ($update_count) {
-      drupal_set_message(format_plural($update_count, 'Changed the content type of 1 post from %old-type to %type.', 'Changed the content type of @count posts from %old-type to %type.', array('%old-type' => $info->old_type, '%type' => $info->type)));
+      set_message(format_plural($update_count, 'Changed the content type of 1 post from %old-type to %type.', 'Changed the content type of @count posts from %old-type to %type.', array('%old-type' => $info->old_type, '%type' => $info->type)));
     }
   }
 }
@@ -450,7 +452,7 @@ function node_type_delete_confirm_submit($form, &$form_state) {
 
   variable_del('node_preview_' . $form_state['values']['type']);
   $t_args = array('%name' => $form_state['values']['name']);
-  drupal_set_message(t('The content type %name has been deleted.', $t_args));
+  set_message(t('The content type %name has been deleted.', $t_args));
   watchdog('menu', 'Deleted content type %name.', $t_args, WATCHDOG_NOTICE);
 
   node_types_rebuild();
diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc
index 9b1968f..198b35e 100644
--- a/core/modules/node/node.admin.inc
+++ b/core/modules/node/node.admin.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -222,7 +223,7 @@ function node_filter_form() {
     $form['filters']['status']['actions']['reset'] = array('#type' => 'submit', '#value' => t('Reset'));
   }
 
-  drupal_add_js('core/misc/form.js');
+  add_js('core/misc/form.js');
 
   return $form;
 }
@@ -290,7 +291,7 @@ function node_mass_update($nodes, $updates) {
       'error_message' => t('The update has encountered an error.'),
       // The operations do not live in the .module file, so we need to
       // tell the batch engine which file to load before calling them.
-      'file' => drupal_get_path('module', 'node') . '/node.admin.inc',
+      'file' => get_path('module', 'node') . '/node.admin.inc',
     );
     batch_set($batch);
   }
@@ -298,7 +299,7 @@ function node_mass_update($nodes, $updates) {
     foreach ($nodes as $nid) {
       _node_mass_update_helper($nid, $updates);
     }
-    drupal_set_message(t('The update has been performed.'));
+    set_message(t('The update has been performed.'));
   }
 }
 
@@ -359,13 +360,13 @@ function _node_mass_update_batch_process($nodes, $updates, &$context) {
  */
 function _node_mass_update_batch_finished($success, $results, $operations) {
   if ($success) {
-    drupal_set_message(t('The update has been performed.'));
+    set_message(t('The update has been performed.'));
   }
   else {
-    drupal_set_message(t('An error occurred and processing did not complete.'), 'error');
+    set_message(t('An error occurred and processing did not complete.'), 'error');
     $message = format_plural(count($results), '1 item successfully processed:', '@count items successfully processed:');
     $message .= theme('item_list', array('items' => $results));
-    drupal_set_message($message);
+    set_message($message);
   }
 }
 
@@ -478,7 +479,7 @@ function node_admin_nodes() {
 
   // Prepare the list of nodes.
   $languages = language_list();
-  $destination = drupal_get_destination();
+  $destination = get_destination();
   $options = array();
   foreach ($nodes as $node) {
     $l_options = $node->language != LANGUAGE_NONE && isset($languages[$node->language]) ? array('language' => $languages[$node->language]) : array();
@@ -607,7 +608,7 @@ function node_admin_nodes_submit($form, &$form_state) {
   $operation = $operations[$form_state['values']['operation']];
   // Filter out unchecked nodes
   $nodes = array_filter($form_state['values']['nodes']);
-  if ($function = $operation['callback']) {
+  if ($operation['callback']) {
     // Add in callback arguments if present.
     if (isset($operation['callback arguments'])) {
       $args = array_merge(array($nodes), $operation['callback arguments']);
@@ -615,7 +616,7 @@ function node_admin_nodes_submit($form, &$form_state) {
     else {
       $args = array($nodes);
     }
-    call_user_func_array($function, $args);
+    call_user_func_array('Drupal\\' . $operation['callback'], $args);
 
     cache_clear_all();
   }
@@ -674,7 +675,7 @@ function node_multiple_delete_confirm_submit($form, &$form_state) {
     node_delete_multiple(array_keys($form_state['values']['nodes']));
     $count = count($form_state['values']['nodes']);
     watchdog('content', 'Deleted @count posts.', array('@count' => $count));
-    drupal_set_message(format_plural($count, 'Deleted 1 post.', 'Deleted @count posts.'));
+    set_message(format_plural($count, 'Deleted 1 post.', 'Deleted @count posts.'));
   }
   $form_state['redirect'] = 'admin/content';
 }
diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php
index c297818..3da6a78 100644
--- a/core/modules/node/node.api.php
+++ b/core/modules/node/node.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -166,7 +167,7 @@
  *   'grant_update' => 0,
  *   'grant_delete' => 0,
  * );
- * drupal_write_record('node_access', $record);
+ * write_record('node_access', $record);
  * @endcode
  * And then in its hook_node_grants() implementation, it would need to return:
  * @code
@@ -483,7 +484,7 @@ function hook_node_predelete($node) {
  * @ingroup node_api_hooks
  */
 function hook_node_delete($node) {
-  drupal_set_message(t('Node: @title has been deleted', array('@title' => $node->title)));
+  set_message(t('Node: @title has been deleted', array('@title' => $node->title)));
 }
 
 /**
@@ -529,7 +530,7 @@ function hook_node_insert($node) {
  * Act on nodes being loaded from the database.
  *
  * This hook is invoked during node loading, which is handled by entity_load(),
- * via classes NodeController and DrupalDefaultEntityController. After the node
+ * via classes NodeController and DefaultEntityController. After the node
  * information is read from the database or the entity cache, hook_load() is
  * invoked on the node's content type module, then field_attach_node_revision()
  * or field_attach_load() is called, then hook_entity_load() is invoked on all
@@ -1155,7 +1156,7 @@ function hook_insert($node) {
  * (use hook_node_load() to respond to all node loads).
  *
  * This hook is invoked during node loading, which is handled by entity_load(),
- * via classes NodeController and DrupalDefaultEntityController. After the node
+ * via classes NodeController and DefaultEntityController. After the node
  * information is read from the database or the entity cache, hook_load() is
  * invoked on the node's content type module, then field_attach_node_revision()
  * or field_attach_load() is called, then hook_entity_load() is invoked on all
@@ -1273,7 +1274,7 @@ function hook_view($node, $view_mode) {
     $breadcrumb[] = l(t('Home'), NULL);
     $breadcrumb[] = l(t('Example'), 'example');
     $breadcrumb[] = l($node->field1, 'example/' . $node->field1);
-    drupal_set_breadcrumb($breadcrumb);
+    set_breadcrumb($breadcrumb);
   }
 
   $node->content['myfield'] = array(
diff --git a/core/modules/node/node.install b/core/modules/node/node.install
index 82fd2e7..91b80c1 100644
--- a/core/modules/node/node.install
+++ b/core/modules/node/node.install
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use PDO, stdClass;
 
 /**
  * @file
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index c7be759..2416990 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -86,7 +88,7 @@ function node_help($path, $arg) {
     else {
       $message = t('The content access permissions need to be rebuilt. <a href="@node_access_rebuild">Rebuild permissions</a>.', array('@node_access_rebuild' => url('admin/reports/status/rebuild')));
     }
-    drupal_set_message($message, 'error');
+    set_message($message, 'error');
   }
 
   switch ($path) {
@@ -761,7 +763,7 @@ function _node_types_build($rebuild = FALSE) {
  */
 function node_type_cache_reset() {
   cache()->deletePrefix('node_types:');
-  drupal_static_reset('_node_types_build');
+  drupal_static_reset('Drupal\_node_types_build');
 }
 
 /**
@@ -889,7 +891,7 @@ function node_hook($node, $hook) {
 function node_invoke($node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
   if (node_hook($node, $hook)) {
     $base = node_type_get_base($node);
-    $function = $base . '_' . $hook;
+    $function = 'Drupal\\' . $base . '_' . $hook;
     return ($function($node, $a2, $a3, $a4));
   }
 }
@@ -1009,12 +1011,12 @@ function node_validate($node, $form, &$form_state) {
   // hook_node_validate() for miscellaneous validation needed by modules. Can't
   // use node_invoke() or module_invoke_all(), because $form_state must be
   // receivable by reference.
-  $function = node_type_get_base($node) . '_validate';
+  $function = 'Drupal\\' . node_type_get_base($node) . '_validate';
   if (function_exists($function)) {
     $function($node, $form, $form_state);
   }
   foreach (module_implements('node_validate') as $module) {
-    $function = $module . '_node_validate';
+    $function = 'Drupal\\' . $module . '_node_validate';
     $function($node, $form, $form_state);
   }
 }
@@ -1097,7 +1099,7 @@ function node_save($node) {
     elseif (!isset($node->log) || $node->log === '') {
       // If we are updating an existing node without adding a new revision, we
       // need to make sure $node->log is unset whenever it is empty. As long as
-      // $node->log is unset, drupal_write_record() will not attempt to update
+      // $node->log is unset, write_record() will not attempt to update
       // the existing database column when re-saving the revision; therefore,
       // this code allows us to avoid clobbering an existing log entry with an
       // empty one.
@@ -1116,14 +1118,14 @@ function node_save($node) {
     if ($node->is_new) {
       // For new nodes, save new records for both the node itself and the node
       // revision.
-      drupal_write_record('node', $node);
+      write_record('node', $node);
       _node_save_revision($node, $user->uid);
       $op = 'insert';
     }
     else {
       // For existing nodes, update the node record which matches the value of
       // $node->nid.
-      drupal_write_record('node', $node, 'nid');
+      write_record('node', $node, 'nid');
       // Then, if a new node revision was requested, save a new record for
       // that; otherwise, update the node revision record which matches the
       // value of $node->vid.
@@ -1149,7 +1151,7 @@ function node_save($node) {
     node_invoke($node, $op);
 
     // Save fields.
-    $function = "field_attach_$op";
+    $function = 'Drupal\field_attach_' . $op;
     $function('node', $node);
 
     module_invoke_all('node_' . $op, $node);
@@ -1198,10 +1200,10 @@ function _node_save_revision($node, $uid, $update = NULL) {
   $temp_uid = $node->uid;
   $node->uid = $uid;
   if (isset($update)) {
-    drupal_write_record('node_revision', $node, $update);
+    write_record('node_revision', $node, $update);
   }
   else {
-    drupal_write_record('node_revision', $node);
+    write_record('node_revision', $node);
   }
   // Have node object still show node owner's uid, not revision author's.
   $node->uid = $temp_uid;
@@ -1353,7 +1355,7 @@ function node_view($node, $view_mode = 'full', $langcode = NULL) {
 
   // Allow modules to modify the structured node.
   $type = 'node';
-  drupal_alter(array('node_view', 'entity_view'), $build, $type);
+  alter(array('node_view', 'entity_view'), $build, $type);
 
   return $build;
 }
@@ -1413,7 +1415,7 @@ function node_build_content($node, $view_mode = 'full', $langcode = NULL) {
   $links = array();
   $node->content['links'] = array(
     '#theme' => 'links__node',
-    '#pre_render' => array('drupal_pre_render_links'),
+    '#pre_render' => array('pre_render_links'),
     '#attributes' => array('class' => array('links', 'inline')),
   );
   if ($view_mode == 'teaser') {
@@ -1454,7 +1456,7 @@ function node_build_content($node, $view_mode = 'full', $langcode = NULL) {
  */
 function node_show($node, $message = FALSE) {
   if ($message) {
-    drupal_set_title(t('Revision of %title from %date', array('%title' => $node->title, '%date' => format_date($node->revision_timestamp))), PASS_THROUGH);
+    set_title(t('Revision of %title from %date', array('%title' => $node->title, '%date' => format_date($node->revision_timestamp))), PASS_THROUGH);
   }
 
   // For markup consistency with other pages, use node_view_multiple() rather than node_view().
@@ -1557,7 +1559,7 @@ function template_preprocess_node(&$variables) {
   $variables['attributes_array']['role'] = 'article';
 
   // Gather node classes.
-  $variables['classes_array'][] = drupal_html_class('node-' . $node->type);
+  $variables['classes_array'][] = html_class('node-' . $node->type);
   if ($variables['promote']) {
     $variables['classes_array'][] = 'node-promoted';
   }
@@ -1698,7 +1700,7 @@ function node_search_admin() {
   );
 
   // Note: reversed to reflect that higher number = higher ranking.
-  $options = drupal_map_assoc(range(0, 10));
+  $options = map_assoc(range(0, 10));
   foreach (module_invoke_all('ranking') as $var => $values) {
     $form['content_ranking']['factors']['node_rank_' . $var] = array(
       '#title' => $values['title'],
@@ -1891,7 +1893,7 @@ function theme_node_search_admin($variables) {
   }
   $output .= theme('table', array('header' => $header, 'rows' => $rows));
 
-  $output .= drupal_render_children($form);
+  $output .= render_children($form);
   return $output;
 }
 
@@ -1981,7 +1983,7 @@ function node_menu() {
   $items['admin/content'] = array(
     'title' => 'Content',
     'description' => 'Find and manage content.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('node_admin_content'),
     'access arguments' => array('access content overview'),
     'weight' => -10,
@@ -1995,7 +1997,7 @@ function node_menu() {
 
   $items['admin/reports/status/rebuild'] = array(
     'title' => 'Rebuild permissions',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('node_configure_rebuild_confirm'),
     // Any user than can potentially trigger a node_access_needs_rebuild(TRUE)
     // has to be allowed access to the 'node access rebuild' confirm form.
@@ -2018,7 +2020,7 @@ function node_menu() {
   );
   $items['admin/structure/types/add'] = array(
     'title' => 'Add content type',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('node_type_form'),
     'access arguments' => array('administer content types'),
     'type' => MENU_LOCAL_ACTION,
@@ -2028,7 +2030,7 @@ function node_menu() {
     'title' => 'Edit content type',
     'title callback' => 'node_type_page_title',
     'title arguments' => array(4),
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('node_type_form', 4),
     'access arguments' => array('administer content types'),
     'file' => 'content_types.inc',
@@ -2082,7 +2084,7 @@ function node_menu() {
   $items['node/%node'] = array(
     'title callback' => 'node_page_title',
     'title arguments' => array(1),
-    // The page callback also invokes drupal_set_title() in case
+    // The page callback also invokes set_title() in case
     // the menu router's title is overridden by a menu link.
     'page callback' => 'node_page_view',
     'page arguments' => array(1),
@@ -2107,7 +2109,7 @@ function node_menu() {
   );
   $items['node/%node/delete'] = array(
     'title' => 'Delete',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('node_delete_confirm', 1),
     'access callback' => 'node_access',
     'access arguments' => array('delete', 1),
@@ -2137,7 +2139,7 @@ function node_menu() {
   $items['node/%node/revisions/%/revert'] = array(
     'title' => 'Revert to earlier revision',
     'load arguments' => array(3),
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('node_revision_revert_confirm', 1),
     'access callback' => '_node_revision_access',
     'access arguments' => array(1, 'update'),
@@ -2146,7 +2148,7 @@ function node_menu() {
   $items['node/%node/revisions/%/delete'] = array(
     'title' => 'Delete earlier revision',
     'load arguments' => array(3),
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('node_revision_delete_confirm', 1),
     'access callback' => '_node_revision_access',
     'access arguments' => array(1, 'delete'),
@@ -2231,7 +2233,7 @@ function node_revision_list($node) {
 function node_block_info() {
   $blocks['syndicate']['info'] = t('Syndicate');
   // Not worth caching.
-  $blocks['syndicate']['cache'] = DRUPAL_NO_CACHE;
+  $blocks['syndicate']['cache'] = NO_CACHE;
 
   $blocks['recent']['info'] = t('Recent content');
   $blocks['recent']['properties']['administrative'] = TRUE;
@@ -2282,7 +2284,7 @@ function node_block_configure($delta = '') {
       '#type' => 'select',
       '#title' => t('Number of recent content items to display'),
       '#default_value' => variable_get('node_recent_block_count', 10),
-      '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
+      '#options' => map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
     );
   }
   return $form;
@@ -2351,7 +2353,7 @@ function theme_node_recent_block($variables) {
   $rows = array();
   $output = '';
 
-  $l_options = array('query' => drupal_get_destination());
+  $l_options = array('query' => get_destination());
   foreach ($variables['nodes'] as $node) {
     $row = array();
     $row[] = array(
@@ -2634,11 +2636,11 @@ function node_feed($nids = FALSE, $channel = array()) {
   $channel = array_merge($channel_defaults, $channel);
 
   $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
-  $output .= "<rss version=\"" . $channel["version"] . "\" xml:base=\"" . $base_url . "\" " . drupal_attributes($namespaces) . ">\n";
+  $output .= "<rss version=\"" . $channel["version"] . "\" xml:base=\"" . $base_url . "\" " . attributes($namespaces) . ">\n";
   $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language'], $channel_extras);
   $output .= "</rss>\n";
 
-  drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
+  add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
   print $output;
 }
 
@@ -2696,15 +2698,15 @@ function node_page_default() {
     $build = node_view_multiple($nodes);
 
     // 'rss.xml' is a path, not a file, registered in node_menu().
-    drupal_add_feed('rss.xml', variable_get('site_name', 'Drupal') . ' ' . t('RSS'));
+    add_feed('rss.xml', variable_get('site_name', 'Drupal') . ' ' . t('RSS'));
     $build['pager'] = array(
       '#theme' => 'pager',
       '#weight' => 5,
     );
-    drupal_set_title('');
+    set_title('');
   }
   else {
-    drupal_set_title(t('Welcome to @site-name', array('@site-name' => variable_get('site_name', 'Drupal'))), PASS_THROUGH);
+    set_title(t('Welcome to @site-name', array('@site-name' => variable_get('site_name', 'Drupal'))), PASS_THROUGH);
 
     $default_message = '<p>' . t('No front page content has been created yet.') . '</p>';
 
@@ -2739,12 +2741,12 @@ function node_page_view($node) {
   // If there is a menu link to this node, the link becomes the last part
   // of the active trail, and the link name becomes the page title.
   // Thus, we must explicitly set the page title to be the node title.
-  drupal_set_title($node->title);
+  set_title($node->title);
   $uri = entity_uri('node', $node);
   // Set the node path as the canonical URL to prevent duplicate content.
-  drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE);
+  add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE);
   // Set the non-aliased path as a default shortlink.
-  drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE);
+  add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE);
   return node_show($node);
 }
 
@@ -2830,7 +2832,7 @@ function node_form_search_form_alter(&$form, $form_state) {
     );
 
     // Node types:
-    $types = array_map('check_plain', node_type_get_names());
+    $types = array_map('Drupal\check_plain', node_type_get_names());
     $form['advanced']['type'] = array(
       '#type' => 'checkboxes',
       '#title' => t('Only of the type(s)'),
@@ -3222,7 +3224,7 @@ function node_access_grants($op, $account = NULL) {
   // Fetch node access grants from other modules.
   $grants = module_invoke_all('node_grants', $account, $op);
   // Allow modules to alter the assigned grants.
-  drupal_alter('node_grants', $grants, $account, $op);
+  alter('node_grants', $grants, $account, $op);
 
   return array_merge(array('all' => array(0)), $grants);
 }
@@ -3369,7 +3371,7 @@ function _node_query_node_access_alter($query, $type) {
         // can triumph that.
         if (!$base_table) {
           // The schema is cached.
-          $schema = drupal_get_schema($table);
+          $schema = get_schema($table);
           if (isset($schema['fields']['nid'])) {
             if (isset($schema['foreign keys'])) {
               foreach ($schema['foreign keys'] as $relation) {
@@ -3503,7 +3505,7 @@ function _node_query_node_access_alter($query, $type) {
 function node_access_acquire_grants($node, $delete = TRUE) {
   $grants = module_invoke_all('node_access_records', $node);
   // Let modules alter the grants.
-  drupal_alter('node_access_records', $grants, $node);
+  alter('node_access_records', $grants, $node);
   // If no grants are set and the node is published, then use the default grant.
   if (empty($grants) && !empty($node->status)) {
     $grants[] = array('realm' => 'all', 'gid' => 0, 'grant_view' => 1, 'grant_update' => 0, 'grant_delete' => 0);
@@ -3658,7 +3660,7 @@ function node_access_rebuild($batch_mode = FALSE) {
   }
 
   if (!isset($batch)) {
-    drupal_set_message(t('Content permissions have been rebuilt.'));
+    set_message(t('Content permissions have been rebuilt.'));
     node_access_needs_rebuild(FALSE);
     cache_clear_all();
   }
@@ -3704,11 +3706,11 @@ function _node_access_rebuild_batch_operation(&$context) {
  */
 function _node_access_rebuild_batch_finished($success, $results, $operations) {
   if ($success) {
-    drupal_set_message(t('The content access permissions have been rebuilt.'));
+    set_message(t('The content access permissions have been rebuilt.'));
     node_access_needs_rebuild(FALSE);
   }
   else {
-    drupal_set_message(t('The content access permissions have not been properly rebuilt.'), 'error');
+    set_message(t('The content access permissions have not been properly rebuilt.'), 'error');
   }
   cache_clear_all();
 }
@@ -4045,7 +4047,7 @@ function node_unpublish_by_keyword_action_form($context) {
     '#title' => t('Keywords'),
     '#type' => 'textarea',
     '#description' => t('The content will be unpublished if it contains any of the phrases above. Use a case-sensitive, comma-separated list of phrases. Example: funny, bungee jumping, "Company, Inc."'),
-    '#default_value' => isset($context['keywords']) ? drupal_implode_tags($context['keywords']) : '',
+    '#default_value' => isset($context['keywords']) ? implode_tags($context['keywords']) : '',
   );
   return $form;
 }
@@ -4054,7 +4056,7 @@ function node_unpublish_by_keyword_action_form($context) {
  * Form submission handler for node_unpublish_by_keyword_action().
  */
 function node_unpublish_by_keyword_action_submit($form, $form_state) {
-  return array('keywords' => drupal_explode_tags($form_state['values']['keywords']));
+  return array('keywords' => explode_tags($form_state['values']['keywords']));
 }
 
 /**
@@ -4146,13 +4148,13 @@ function node_modules_disabled($modules) {
 /**
  * Controller class for nodes.
  *
- * This extends the DrupalDefaultEntityController class, adding required
+ * This extends the DefaultEntityController class, adding required
  * special handling for node objects.
  */
-class NodeController extends DrupalDefaultEntityController {
+class NodeController extends DefaultEntityController {
 
   /**
-   * Overrides DrupalDefaultEntityController::attachLoad().
+   * Overrides DefaultEntityController::attachLoad().
    */
   protected function attachLoad(&$nodes, $revision_id = FALSE) {
     // Create an array of nodes for each content type and pass this to the
@@ -4165,7 +4167,7 @@ class NodeController extends DrupalDefaultEntityController {
     // Call object type specific callbacks on each typed array of nodes.
     foreach ($typed_nodes as $node_type => $nodes_of_type) {
       if (node_hook($node_type, 'load')) {
-        $function = node_type_get_base($node_type) . '_load';
+        $function = 'Drupal\\' . node_type_get_base($node_type) . '_load';
         $function($nodes_of_type);
       }
     }
@@ -4177,7 +4179,7 @@ class NodeController extends DrupalDefaultEntityController {
   }
 
   /**
-   * Overrides DrupalDefaultEntityController::buildQuery().
+   * Overrides DefaultEntityController::buildQuery().
    */
   protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
     // Ensure that uid is taken from the {node} table,
diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc
index cd1eb6d..bce6bb8 100644
--- a/core/modules/node/node.pages.inc
+++ b/core/modules/node/node.pages.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -19,8 +20,8 @@
  */
 function node_page_edit($node) {
   $type_name = node_type_get_name($node);
-  drupal_set_title(t('<em>Edit @type</em> @title', array('@type' => $type_name, '@title' => $node->title)), PASS_THROUGH);
-  return drupal_get_form($node->type . '_node_form', $node);
+  set_title(t('<em>Edit @type</em> @title', array('@type' => $type_name, '@title' => $node->title)), PASS_THROUGH);
+  return get_form($node->type . '_node_form', $node);
 }
 
 /**
@@ -36,7 +37,7 @@ function node_add_page() {
   // Bypass the node/add listing if only one content type is available.
   if (count($content) == 1) {
     $item = array_shift($content);
-    drupal_goto($item['href']);
+    redirect($item['href']);
   }
   return theme('node_add_list', array('content' => $content));
 }
@@ -88,8 +89,8 @@ function node_add($type) {
 
   $types = node_type_get_types();
   $node = (object) array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => LANGUAGE_NONE);
-  drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)), PASS_THROUGH);
-  $output = drupal_get_form($type . '_node_form', $node);
+  set_title(t('Create @name', array('@name' => $types[$type]->name)), PASS_THROUGH);
+  $output = get_form($type . '_node_form', $node);
 
   return $output;
 }
@@ -149,7 +150,7 @@ function node_form($form, &$form_state, $node) {
 
   // Override the default CSS class name, since the user-defined node type name
   // in 'TYPE-node-form' potentially clashes with third-party class names.
-  $form['#attributes']['class'][0] = drupal_html_class('node-' . $node->type . '-form');
+  $form['#attributes']['class'][0] = html_class('node-' . $node->type . '-form');
 
   // Basic node information.
   // These elements are just values so they are not even sent to the client.
@@ -169,7 +170,7 @@ function node_form($form, &$form_state, $node) {
   // because hook_form() needs to be able to receive $form_state by reference.
   // @todo hook_form() implementations are unable to add #validate or #submit
   //   handlers to the form buttons below. Remove hook_form() entirely.
-  $function = node_type_get_base($node) . '_form';
+  $function = 'Drupal\\' . node_type_get_base($node) . '_form';
   if (function_exists($function) && ($extra = $function($node, $form_state))) {
     $form = array_merge_recursive($form, $extra);
   }
@@ -199,7 +200,7 @@ function node_form($form, &$form_state, $node) {
       'class' => array('node-form-revision-information'),
     ),
     '#attached' => array(
-      'js' => array(drupal_get_path('module', 'node') . '/node.js'),
+      'js' => array(get_path('module', 'node') . '/node.js'),
     ),
     '#weight' => 20,
     '#access' => $node->revision || user_access('administer nodes'),
@@ -241,7 +242,7 @@ function node_form($form, &$form_state, $node) {
     ),
     '#attached' => array(
       'js' => array(
-        drupal_get_path('module', 'node') . '/node.js',
+        get_path('module', 'node') . '/node.js',
         array(
           'type' => 'setting',
           'data' => array('anonymous' => variable_get('anonymous', t('Anonymous'))),
@@ -279,7 +280,7 @@ function node_form($form, &$form_state, $node) {
       'class' => array('node-form-options'),
     ),
     '#attached' => array(
-      'js' => array(drupal_get_path('module', 'node') . '/node.js'),
+      'js' => array(get_path('module', 'node') . '/node.js'),
     ),
     '#weight' => 95,
   );
@@ -303,13 +304,13 @@ function node_form($form, &$form_state, $node) {
   $form['actions'] = array('#type' => 'actions');
   $form['actions']['submit'] = array(
     '#type' => 'submit',
-    '#access' => variable_get('node_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_REQUIRED || (!form_get_errors() && isset($form_state['node_preview'])),
+    '#access' => variable_get('node_preview_' . $node->type, OPTIONAL) != REQUIRED || (!form_get_errors() && isset($form_state['node_preview'])),
     '#value' => t('Save'),
     '#weight' => 5,
     '#submit' => array('node_form_submit'),
   );
   $form['actions']['preview'] = array(
-    '#access' => variable_get('node_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_DISABLED,
+    '#access' => variable_get('node_preview_' . $node->type, OPTIONAL) != DISABLED,
     '#type' => 'submit',
     '#value' => t('Preview'),
     '#weight' => 10,
@@ -330,7 +331,7 @@ function node_form($form, &$form_state, $node) {
   // handler for the 'Save' action. To maintain backwards compatibility, a
   // #submit handler is auto-suggested for custom node type modules.
   $form['#validate'][] = 'node_form_validate';
-  if (!isset($form['#submit']) && function_exists($node->type . '_node_form_submit')) {
+  if (!isset($form['#submit']) && function_exists('Drupal\\' . $node->type . '_node_form_submit')) {
     $form['#submit'][] = $node->type . '_node_form_submit';
   }
   $form += array('#submit' => array());
@@ -350,7 +351,7 @@ function node_form($form, &$form_state, $node) {
 function node_form_delete_submit($form, &$form_state) {
   $destination = array();
   if (isset($_GET['destination'])) {
-    $destination = drupal_get_destination();
+    $destination = get_destination();
     unset($_GET['destination']);
   }
   $node = $form['#node'];
@@ -413,7 +414,7 @@ function node_preview($node) {
       $output = theme('node_preview', array('node' => $node));
       unset($node->in_preview);
     }
-    drupal_set_title(t('Preview'), PASS_THROUGH);
+    set_title(t('Preview'), PASS_THROUGH);
 
     return $output;
   }
@@ -443,7 +444,7 @@ function theme_node_preview($variables) {
 
   // Do we need to preview trimmed version of post as well as full version?
   if ($trimmed != $full) {
-    drupal_set_message(t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication.<span class="no-js"> You can insert the delimiter "&lt;!--break--&gt;" (without the quotes) to fine-tune where your post gets split.</span>'));
+    set_message(t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication.<span class="no-js"> You can insert the delimiter "&lt;!--break--&gt;" (without the quotes) to fine-tune where your post gets split.</span>'));
     $output .= '<h3>' . t('Preview trimmed version') . '</h3>';
     $output .= $trimmed;
     $output .= '<h3>' . t('Preview full version') . '</h3>';
@@ -475,11 +476,11 @@ function node_form_submit($form, &$form_state) {
 
   if ($insert) {
     watchdog('content', '@type: added %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
-    drupal_set_message(t('@type %title has been created.', $t_args));
+    set_message(t('@type %title has been created.', $t_args));
   }
   else {
     watchdog('content', '@type: updated %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
-    drupal_set_message(t('@type %title has been updated.', $t_args));
+    set_message(t('@type %title has been updated.', $t_args));
   }
   if ($node->nid) {
     $form_state['values']['nid'] = $node->nid;
@@ -489,7 +490,7 @@ function node_form_submit($form, &$form_state) {
   else {
     // In the unlikely case something went wrong on save, the node will be
     // rebuilt and node form redisplayed the same way as in preview.
-    drupal_set_message(t('The post could not be saved.'), 'error');
+    set_message(t('The post could not be saved.'), 'error');
     $form_state['rebuild'] = TRUE;
   }
   // Clear the page and block caches.
@@ -527,7 +528,7 @@ function node_form_submit_build_node($form, &$form_state) {
 
   node_submit($node);
   foreach (module_implements('node_submit') as $module) {
-    $function = $module . '_node_submit';
+    $function = 'Drupal\\' . $module . '_node_submit';
     $function($node, $form, $form_state);
   }
   return $node;
@@ -561,7 +562,7 @@ function node_delete_confirm_submit($form, &$form_state) {
     $node = node_load($form_state['values']['nid']);
     node_delete($form_state['values']['nid']);
     watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
-    drupal_set_message(t('@type %title has been deleted.', array('@type' => node_type_get_name($node), '%title' => $node->title)));
+    set_message(t('@type %title has been deleted.', array('@type' => node_type_get_name($node), '%title' => $node->title)));
   }
 
   $form_state['redirect'] = '<front>';
@@ -575,7 +576,7 @@ function node_delete_confirm_submit($form, &$form_state) {
  * @see node_menu()
  */
 function node_revision_overview($node) {
-  drupal_set_title(t('Revisions for %title', array('%title' => $node->title)), PASS_THROUGH);
+  set_title(t('Revisions for %title', array('%title' => $node->title)), PASS_THROUGH);
 
   $header = array(t('Revision'), array('data' => t('Operations'), 'colspan' => 2));
 
@@ -598,7 +599,7 @@ function node_revision_overview($node) {
       $row[] = array('data' => t('!date by !username', array('!date' => l(format_date($revision->timestamp, 'short'), "node/$node->nid"), '!username' => theme('username', array('account' => $revision))))
                                . (($revision->log != '') ? '<p class="revision-log">' . filter_xss($revision->log) . '</p>' : ''),
                      'class' => array('revision-current'));
-      $operations[] = array('data' => drupal_placeholder(t('current revision')), 'class' => array('revision-current'), 'colspan' => 2);
+      $operations[] = array('data' => placeholder(t('current revision')), 'class' => array('revision-current'), 'colspan' => 2);
     }
     else {
       $row[] = t('!date by !username', array('!date' => l(format_date($revision->timestamp, 'short'), "node/$node->nid/revisions/$revision->vid/view"), '!username' => theme('username', array('account' => $revision))))
@@ -648,7 +649,7 @@ function node_revision_revert_confirm_submit($form, &$form_state) {
   node_save($node_revision);
 
   watchdog('content', '@type: reverted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->title, '%revision' => $node_revision->vid));
-  drupal_set_message(t('@type %title has been reverted back to the revision from %revision-date.', array('@type' => node_type_get_name($node_revision), '%title' => $node_revision->title, '%revision-date' => format_date($node_revision->revision_timestamp))));
+  set_message(t('@type %title has been reverted back to the revision from %revision-date.', array('@type' => node_type_get_name($node_revision), '%title' => $node_revision->title, '%revision-date' => format_date($node_revision->revision_timestamp))));
   $form_state['redirect'] = 'node/' . $node_revision->nid . '/revisions';
 }
 
@@ -675,7 +676,7 @@ function node_revision_delete_confirm_submit($form, &$form_state) {
   node_revision_delete($node_revision->vid);
 
   watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->title, '%revision' => $node_revision->vid));
-  drupal_set_message(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($node_revision->revision_timestamp), '@type' => node_type_get_name($node_revision), '%title' => $node_revision->title)));
+  set_message(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($node_revision->revision_timestamp), '@type' => node_type_get_name($node_revision), '%title' => $node_revision->title)));
   $form_state['redirect'] = 'node/' . $node_revision->nid;
   if (db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid', array(':nid' => $node_revision->nid))->fetchField() > 1) {
     $form_state['redirect'] .= '/revisions';
diff --git a/core/modules/node/node.test b/core/modules/node/node.test
index f828164..a1b69eb 100644
--- a/core/modules/node/node.test
+++ b/core/modules/node/node.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -8,7 +10,7 @@
 /**
  * Tests the node_load_multiple() function.
  */
-class NodeLoadMultipleUnitTest extends DrupalWebTestCase {
+class NodeLoadMultipleUnitTest extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -88,7 +90,7 @@ class NodeLoadMultipleUnitTest extends DrupalWebTestCase {
 /**
  * Tests for the hooks invoked during node_load().
  */
-class NodeLoadHooksTestCase extends DrupalWebTestCase {
+class NodeLoadHooksTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Node load hooks',
@@ -129,7 +131,7 @@ class NodeLoadHooksTestCase extends DrupalWebTestCase {
   }
 }
 
-class NodeRevisionsTestCase extends DrupalWebTestCase {
+class NodeRevisionsTestCase extends WebTestCase {
   protected $nodes;
   protected $logs;
 
@@ -262,7 +264,7 @@ class NodeRevisionsTestCase extends DrupalWebTestCase {
   }
 }
 
-class PageEditTestCase extends DrupalWebTestCase {
+class PageEditTestCase extends WebTestCase {
   protected $web_user;
   protected $admin_user;
 
@@ -394,7 +396,7 @@ class PageEditTestCase extends DrupalWebTestCase {
   }
 }
 
-class PagePreviewTestCase extends DrupalWebTestCase {
+class PagePreviewTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Node preview',
@@ -465,7 +467,7 @@ class PagePreviewTestCase extends DrupalWebTestCase {
   }
 }
 
-class NodeCreationTestCase extends DrupalWebTestCase {
+class NodeCreationTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Node creation',
@@ -543,7 +545,7 @@ class NodeCreationTestCase extends DrupalWebTestCase {
   }
 }
 
-class PageViewTestCase extends DrupalWebTestCase {
+class PageViewTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Node edit permissions',
@@ -582,7 +584,7 @@ class PageViewTestCase extends DrupalWebTestCase {
   }
 }
 
-class SummaryLengthTestCase extends DrupalWebTestCase {
+class SummaryLengthTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Summary length',
@@ -624,7 +626,7 @@ class SummaryLengthTestCase extends DrupalWebTestCase {
   }
 }
 
-class NodeTitleXSSTestCase extends DrupalWebTestCase {
+class NodeTitleXSSTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Node title XSS filtering',
@@ -658,7 +660,7 @@ class NodeTitleXSSTestCase extends DrupalWebTestCase {
   }
 }
 
-class NodeBlockTestCase extends DrupalWebTestCase {
+class NodeBlockTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Block availability',
@@ -691,7 +693,7 @@ class NodeBlockTestCase extends DrupalWebTestCase {
 /**
  * Check that the post information displays when enabled for a content type.
  */
-class NodePostSettingsTestCase extends DrupalWebTestCase {
+class NodePostSettingsTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Node post information display',
@@ -760,7 +762,7 @@ class NodePostSettingsTestCase extends DrupalWebTestCase {
  * added to the node->content array, then verify that the data appears on the
  * sitewide RSS feed at rss.xml.
  */
-class NodeRSSContentTestCase extends DrupalWebTestCase {
+class NodeRSSContentTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Node RSS Content',
@@ -821,7 +823,7 @@ class NodeRSSContentTestCase extends DrupalWebTestCase {
  * @todo Cover hook_node_access in a separate test class.
  * hook_node_access_records is covered in another test class.
  */
-class NodeAccessUnitTest extends DrupalWebTestCase {
+class NodeAccessUnitTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Node access',
@@ -844,7 +846,7 @@ class NodeAccessUnitTest extends DrupalWebTestCase {
     parent::setUp();
     // Clear permissions for authenticated users.
     db_delete('role_permission')
-      ->condition('rid', DRUPAL_AUTHENTICATED_RID)
+      ->condition('rid', AUTHENTICATED_RID)
       ->execute();
   }
 
@@ -888,7 +890,7 @@ class NodeAccessUnitTest extends DrupalWebTestCase {
 /**
  * Test case to verify hook_node_access_records functionality.
  */
-class NodeAccessRecordsUnitTest extends DrupalWebTestCase {
+class NodeAccessRecordsUnitTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Node access records',
@@ -956,7 +958,7 @@ class NodeAccessRecordsUnitTest extends DrupalWebTestCase {
     foreach ($operations as $op) {
       $grants = node_test_node_grants($op, $web_user);
       $altered_grants = $grants;
-      drupal_alter('node_grants', $altered_grants, $web_user, $op);
+      alter('node_grants', $altered_grants, $web_user, $op);
       $this->assertNotEqual($grants, $altered_grants, t('Altered the %op grant for a user.', array('%op' => $op)));
     }
 
@@ -971,7 +973,7 @@ class NodeAccessRecordsUnitTest extends DrupalWebTestCase {
 /**
  * Tests for Node Access with a non-node base table.
  */
-class NodeAccessBaseTableTestCase extends DrupalWebTestCase {
+class NodeAccessBaseTableTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1130,7 +1132,7 @@ class NodeAccessBaseTableTestCase extends DrupalWebTestCase {
 /**
  * Test case to check node save related functionality, including import-save
  */
-class NodeSaveTestCase extends DrupalWebTestCase {
+class NodeSaveTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1273,7 +1275,7 @@ class NodeSaveTestCase extends DrupalWebTestCase {
 /**
  * Tests related to node types.
  */
-class NodeTypeTestCase extends DrupalWebTestCase {
+class NodeTypeTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Node types',
@@ -1427,7 +1429,7 @@ class NodeTypeTestCase extends DrupalWebTestCase {
 /**
  * Test node type customizations persistence.
  */
-class NodeTypePersistenceTestCase extends DrupalWebTestCase {
+class NodeTypePersistenceTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Node type persist',
@@ -1503,7 +1505,7 @@ class NodeTypePersistenceTestCase extends DrupalWebTestCase {
 /**
  * Rebuild the node_access table.
  */
-class NodeAccessRebuildTestCase extends DrupalWebTestCase {
+class NodeAccessRebuildTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Node access rebuild',
@@ -1531,7 +1533,7 @@ class NodeAccessRebuildTestCase extends DrupalWebTestCase {
 /**
  * Test node administration page functionality.
  */
-class NodeAdminTestCase extends DrupalWebTestCase {
+class NodeAdminTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Node administration',
@@ -1546,7 +1548,7 @@ class NodeAdminTestCase extends DrupalWebTestCase {
     // Remove the "view own unpublished content" permission which is set
     // by default for authenticated users so we can test this permission
     // correctly.
-    user_role_revoke_permissions(DRUPAL_AUTHENTICATED_RID, array('view own unpublished content'));
+    user_role_revoke_permissions(AUTHENTICATED_RID, array('view own unpublished content'));
 
     $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'access content overview', 'administer nodes', 'bypass node access'));
     $this->base_user_1 = $this->drupalCreateUser(array('access content overview'));
@@ -1696,7 +1698,7 @@ class NodeAdminTestCase extends DrupalWebTestCase {
 /**
  * Test node title.
  */
-class NodeTitleTestCase extends DrupalWebTestCase {
+class NodeTitleTestCase extends WebTestCase {
   protected $admin_user;
 
   public static function getInfo() {
@@ -1747,7 +1749,7 @@ class NodeTitleTestCase extends DrupalWebTestCase {
 /**
  * Test the node_feed() functionality.
  */
-class NodeFeedTestCase extends DrupalWebTestCase {
+class NodeFeedTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Node feed',
@@ -1771,7 +1773,7 @@ class NodeFeedTestCase extends DrupalWebTestCase {
 /**
  * Functional tests for the node module blocks.
  */
-class NodeBlockFunctionalTest extends DrupalWebTestCase {
+class NodeBlockFunctionalTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Node blocks',
@@ -1795,7 +1797,7 @@ class NodeBlockFunctionalTest extends DrupalWebTestCase {
     $this->drupalLogin($this->admin_user);
 
     // Disallow anonymous users to view content.
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(ANONYMOUS_RID, array(
       'access content' => FALSE,
     ));
 
@@ -1907,7 +1909,7 @@ class NodeBlockFunctionalTest extends DrupalWebTestCase {
 /**
  * Test multistep node forms basic options.
  */
-class MultiStepNodeFormBasicOptionsTest extends DrupalWebTestCase {
+class MultiStepNodeFormBasicOptionsTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Multistep node form basic options',
@@ -1944,7 +1946,7 @@ class MultiStepNodeFormBasicOptionsTest extends DrupalWebTestCase {
 /**
  * Test to ensure that a node's content is always rebuilt.
  */
-class NodeBuildContent extends DrupalWebTestCase {
+class NodeBuildContent extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1972,7 +1974,7 @@ class NodeBuildContent extends DrupalWebTestCase {
 /**
  * Tests node_query_node_access_alter().
  */
-class NodeQueryAlter extends DrupalWebTestCase {
+class NodeQueryAlter extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -2115,11 +2117,11 @@ class NodeQueryAlter extends DrupalWebTestCase {
       'grant_update' => 0,
       'grant_delete' => 0,
     );
-    drupal_write_record('node_access', $record);
+    write_record('node_access', $record);
 
     // Test that the noAccessUser still doesn't have the 'view'
     // privilege after adding the node_access record.
-    drupal_static_reset('node_access_view_all_nodes');
+    drupal_static_reset('Drupal\node_access_view_all_nodes');
     try {
       $query = db_select('node', 'mytab')
         ->fields('mytab');
@@ -2141,7 +2143,7 @@ class NodeQueryAlter extends DrupalWebTestCase {
     // noAccessUser2.
     $this->drupalLogin($this->noAccessUser2);
     variable_set('node_test_node_access_all_uid', $this->noAccessUser->uid);
-    drupal_static_reset('node_access_view_all_nodes');
+    drupal_static_reset('Drupal\node_access_view_all_nodes');
     try {
       $query = db_select('node', 'mytab')
         ->fields('mytab');
@@ -2163,7 +2165,7 @@ class NodeQueryAlter extends DrupalWebTestCase {
 /**
  * Tests node_query_entity_field_access_alter().
  */
-class NodeEntityFieldQueryAlter extends DrupalWebTestCase {
+class NodeEntityFieldQueryAlter extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -2227,7 +2229,7 @@ class NodeEntityFieldQueryAlter extends DrupalWebTestCase {
 /**
  * Test node token replacement in strings.
  */
-class NodeTokenReplaceTestCase extends DrupalWebTestCase {
+class NodeTokenReplaceTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Node token replacement',
diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc
index abe864a..114605b 100644
--- a/core/modules/node/node.tokens.inc
+++ b/core/modules/node/node.tokens.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/node/node.tpl.php b/core/modules/node/node.tpl.php
index adb9aa2..f441736 100644
--- a/core/modules/node/node.tpl.php
+++ b/core/modules/node/node.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/node/tests/node_access_test.install b/core/modules/node/tests/node_access_test.install
index 6b3ef5d..5c55145 100644
--- a/core/modules/node/tests/node_access_test.install
+++ b/core/modules/node/tests/node_access_test.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/node/tests/node_access_test.module b/core/modules/node/tests/node_access_test.module
index f946573..faa5284 100644
--- a/core/modules/node/tests/node_access_test.module
+++ b/core/modules/node/tests/node_access_test.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
diff --git a/core/modules/node/tests/node_test.module b/core/modules/node/tests/node_test.module
index b0ebc14..97d3c6b 100644
--- a/core/modules/node/tests/node_test.module
+++ b/core/modules/node/tests/node_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/node/tests/node_test_exception.module b/core/modules/node/tests/node_test_exception.module
index 0fe9f35..6e15c6d 100644
--- a/core/modules/node/tests/node_test_exception.module
+++ b/core/modules/node/tests/node_test_exception.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
diff --git a/core/modules/openid/openid.api.php b/core/modules/openid/openid.api.php
index bd286ff..3ca9d6c 100644
--- a/core/modules/openid/openid.api.php
+++ b/core/modules/openid/openid.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/openid/openid.inc b/core/modules/openid/openid.inc
index b4d7a32..d618921 100644
--- a/core/modules/openid/openid.inc
+++ b/core/modules/openid/openid.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use DOMDocument, Exception, SimpleXMLElement;
 
 /**
  * @file
@@ -92,7 +94,7 @@ function openid_redirect($url, $message) {
   $output .= "<title>" . t('OpenID redirect') . "</title>\n";
   $output .= "</head>\n";
   $output .= "<body>\n";
-  $elements = drupal_get_form('openid_redirect_form', $url, $message);
+  $elements = get_form('openid_redirect_form', $url, $message);
   $output .= drupal_render($elements);
   $output .= '<script type="text/javascript">document.getElementById("openid-redirect-form").submit();</script>' . "\n";
   $output .= "</body>\n";
@@ -248,12 +250,13 @@ function _openid_is_xri($identifier) {
  */
 function openid_normalize($identifier) {
   $methods = module_invoke_all('openid_normalization_method_info');
-  drupal_alter('openid_normalization_method_info', $methods);
+  alter('openid_normalization_method_info', $methods);
 
   // Execute each method in turn, stopping after the first method accepted
   // the identifier.
   foreach ($methods as $method) {
-    $result = $method($identifier);
+    $function = 'Drupal\\' . $method;
+    $result = $function($identifier);
     if ($result !== NULL) {
       $identifier = $result;
       break;
diff --git a/core/modules/openid/openid.install b/core/modules/openid/openid.install
index 2df39aa..2a5f3fc 100644
--- a/core/modules/openid/openid.install
+++ b/core/modules/openid/openid.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/openid/openid.module b/core/modules/openid/openid.module
index edd73d3..d26114b 100644
--- a/core/modules/openid/openid.module
+++ b/core/modules/openid/openid.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -27,7 +28,7 @@ function openid_menu() {
   );
   $items['user/%user/openid/delete'] = array(
     'title' => 'Delete OpenID',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('openid_user_delete_form', 1),
     'access callback' => 'user_edit_access',
     'access arguments' => array(1),
@@ -87,7 +88,7 @@ function openid_user_insert(&$edit, $account) {
   if (!empty($edit['openid_claimed_id'])) {
     // The user has registered after trying to log in via OpenID.
     if (variable_get('user_email_verification', TRUE)) {
-      drupal_set_message(t('Once you have verified your e-mail address, you may log in via OpenID.'));
+      set_message(t('Once you have verified your e-mail address, you may log in via OpenID.'));
     }
     user_set_authmaps($account, array('authname_openid' => $edit['openid_claimed_id']));
     unset($_SESSION['openid']);
@@ -134,8 +135,8 @@ function openid_form_user_login_alter(&$form, &$form_state) {
 }
 
 function _openid_user_login_form_alter(&$form, &$form_state) {
-  $form['#attached']['css'][] = drupal_get_path('module', 'openid') . '/openid.css';
-  $form['#attached']['js'][] = drupal_get_path('module', 'openid') . '/openid.js';
+  $form['#attached']['css'][] = get_path('module', 'openid') . '/openid.css';
+  $form['#attached']['js'][] = get_path('module', 'openid') . '/openid.js';
   $form['#attached']['library'][] = array('system', 'jquery.cookie');
   if (!empty($form_state['input']['openid_identifier'])) {
     $form['name']['#required'] = FALSE;
@@ -460,11 +461,12 @@ function openid_discovery($claimed_id) {
   module_load_include('inc', 'openid');
 
   $methods = module_invoke_all('openid_discovery_method_info');
-  drupal_alter('openid_discovery_method_info', $methods);
+  alter('openid_discovery_method_info', $methods);
 
   // Execute each method in turn and return first successful discovery.
   foreach ($methods as $method) {
-    $discovery = $method($claimed_id);
+    $function = 'Drupal\\' . $method;
+    $discovery = $function($claimed_id);
     if (!empty($discovery)) {
       return $discovery;
     }
@@ -543,11 +545,11 @@ function _openid_xrds_discovery($claimed_id) {
   if ($scheme == 'http' || $scheme == 'https') {
     // For regular URLs, try Yadis resolution first, then HTML-based discovery
     $headers = array('Accept' => 'application/xrds+xml');
-    $result = drupal_http_request($xrds_url, array('headers' => $headers));
+    $result = http_request($xrds_url, array('headers' => $headers));
 
     // Check for HTTP error and make sure, that we reach the target. If the
     // maximum allowed redirects are exhausted, final destination URL isn't
-    // reached, but drupal_http_request() doesn't return any error.
+    // reached, but http_request() doesn't return any error.
     // @todo Remove the check for 200 HTTP result code after the following issue
     // will be fixed: http://drupal.org/node/1096890.
     if (!isset($result->error) && $result->code == 200) {
@@ -572,7 +574,7 @@ function _openid_xrds_discovery($claimed_id) {
         }
         if (!empty($xrds_url)) {
           $headers = array('Accept' => 'application/xrds+xml');
-          $xrds_result = drupal_http_request($xrds_url, array('headers' => $headers));
+          $xrds_result = http_request($xrds_url, array('headers' => $headers));
           if (!isset($xrds_result->error)) {
             $services = _openid_xrds_parse($xrds_result->data);
           }
@@ -658,7 +660,7 @@ function openid_association($op_endpoint) {
       'method' => 'POST',
       'data' => $assoc_message,
     );
-    $assoc_result = drupal_http_request($op_endpoint, $assoc_options);
+    $assoc_result = http_request($op_endpoint, $assoc_options);
     if (isset($assoc_result->error)) {
       return FALSE;
     }
@@ -711,7 +713,7 @@ function openid_authentication($response) {
       }
     }
     else {
-      drupal_set_message(t('You must validate your email address for this account before logging in via OpenID.'));
+      set_message(t('You must validate your email address for this account before logging in via OpenID.'));
     }
     // Let other modules act on OpenID login
     module_invoke_all('openid_response', $response, $account);
@@ -724,42 +726,42 @@ function openid_authentication($response) {
 
     $form_state['values'] = array();
     $form_state['values']['op'] = t('Create new account');
-    drupal_form_submit('user_register_form', $form_state);
+    form_submit('user_register_form', $form_state);
 
     if (empty($form_state['user'])) {
       module_invoke_all('openid_response', $response, NULL);
     }
     else {
       module_invoke_all('openid_response', $response, $form_state['user']);
-      drupal_goto();
+      redirect();
     }
 
-    $messages = drupal_get_messages('error');
+    $messages = get_messages('error');
     if (empty($form_state['values']['name']) || empty($form_state['values']['mail'])) {
       // If the OpenID provider did not provide both a user name and an email
       // address, ask the user to complete the registration manually instead of
       // showing the error messages about the missing values generated by FAPI.
-      drupal_set_message(t('Complete the registration by filling out the form below. If you already have an account, you can <a href="@login">log in</a> now and add your OpenID under "My account".', array('@login' => url('user/login'))), 'warning');
+      set_message(t('Complete the registration by filling out the form below. If you already have an account, you can <a href="@login">log in</a> now and add your OpenID under "My account".', array('@login' => url('user/login'))), 'warning');
     }
     else {
-      drupal_set_message(t('Account registration using the information provided by your OpenID provider failed due to the reasons listed below. Complete the registration by filling out the form below. If you already have an account, you can <a href="@login">log in</a> now and add your OpenID under "My account".', array('@login' => url('user/login'))), 'warning');
+      set_message(t('Account registration using the information provided by your OpenID provider failed due to the reasons listed below. Complete the registration by filling out the form below. If you already have an account, you can <a href="@login">log in</a> now and add your OpenID under "My account".', array('@login' => url('user/login'))), 'warning');
       // Append form validation errors below the above warning.
       foreach ($messages['error'] as $message) {
-        drupal_set_message( $message, 'error');
+        set_message( $message, 'error');
       }
     }
 
     // We were unable to register a valid new user. Redirect to the normal
     // registration page and prefill with the values we received.
-    $destination = drupal_get_destination();
+    $destination = get_destination();
     unset($_GET['destination']);
-    drupal_goto('user/register', array('query' => $destination));
+    redirect('user/register', array('query' => $destination));
   }
   else {
-    drupal_set_message(t('Only site administrators can create new user accounts.'), 'error');
+    set_message(t('Only site administrators can create new user accounts.'), 'error');
     module_invoke_all('openid_response', $response, NULL);
   }
-  drupal_goto();
+  redirect();
 }
 
 function openid_association_request($public) {
@@ -834,7 +836,7 @@ function openid_authentication_request($claimed_id, $identity, $return_to = '',
     $request['openid.ax.type.language_son'] = 'http://openid.net/schema/language/pref';
   }
 
-  drupal_alter('openid_request', $request, $service);
+  alter('openid_request', $request, $service);
 
   return $request;
 }
@@ -895,7 +897,7 @@ function openid_verify_assertion($service, $response) {
       'method' => 'POST',
       'data' => _openid_encode_message($message),
     );
-    $result = drupal_http_request($service['uri'], $options);
+    $result = http_request($service['uri'], $options);
     if (!isset($result->error)) {
       $response = _openid_parse_message($result->data);
 
diff --git a/core/modules/openid/openid.pages.inc b/core/modules/openid/openid.pages.inc
index 885fe1d..ace506a 100644
--- a/core/modules/openid/openid.pages.inc
+++ b/core/modules/openid/openid.pages.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -14,21 +15,21 @@ function openid_authentication_page() {
     case 'success':
       return openid_authentication($result);
     case 'failed':
-      drupal_set_message(t('OpenID login failed.'), 'error');
+      set_message(t('OpenID login failed.'), 'error');
       break;
     case 'cancel':
-      drupal_set_message(t('OpenID login cancelled.'));
+      set_message(t('OpenID login cancelled.'));
       break;
   }
-  drupal_goto();
+  redirect();
 }
 
 /**
  * Menu callback; Manage OpenID identities for the specified user.
  */
 function openid_user_identities($account) {
-  drupal_set_title(user_format_name($account));
-  drupal_add_css(drupal_get_path('module', 'openid') . '/openid.css');
+  set_title(user_format_name($account));
+  add_css(get_path('module', 'openid') . '/openid.css');
 
   // Check to see if we got a response
   $response = openid_complete();
@@ -41,7 +42,7 @@ function openid_user_identities($account) {
         'module' => 'openid',
       ))
       ->execute();
-    drupal_set_message(t('Successfully added %identity', array('%identity' => $identity)));
+    set_message(t('Successfully added %identity', array('%identity' => $identity)));
     // Let other modules act on OpenID authentication.
     module_invoke_all('openid_response', $response, $account);
   }
@@ -59,7 +60,7 @@ function openid_user_identities($account) {
     '#header' => $header,
     '#rows' => $rows,
   );
-  $build['openid_user_add'] = drupal_get_form('openid_user_add');
+  $build['openid_user_add'] = get_form('openid_user_add');
   return $build;
 }
 
@@ -111,7 +112,7 @@ function openid_user_delete_form_submit($form, &$form_state) {
     ->condition('module', 'openid')
     ->execute();
   if ($query) {
-    drupal_set_message(t('OpenID deleted.'));
+    set_message(t('OpenID deleted.'));
   }
   $form_state['redirect'] = 'user/' . $form_state['build_info']['args'][0]->uid . '/openid';
 }
diff --git a/core/modules/openid/openid.test b/core/modules/openid/openid.test
index 5c6ca69..806b37f 100644
--- a/core/modules/openid/openid.test
+++ b/core/modules/openid/openid.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -8,7 +10,7 @@
 /**
  * Base class for OpenID tests.
  */
-abstract class OpenIDWebTestCase extends DrupalWebTestCase {
+abstract class OpenIDWebTestCase extends WebTestCase {
 
   /**
    * Initiates the login procedure using the specified User-supplied Identity.
@@ -137,12 +139,12 @@ class OpenIDFunctionalTestCase extends OpenIDWebTestCase {
     $this->addRedirectedIdentity($identity, 2, 'http://example.com/xrds', $expected_claimed_id, 0);
 
     // Exact 3 redirects (default value for the 'max_redirects' option in
-    // drupal_http_request()).
+    // http_request()).
     $identity = $expected_claimed_id = url('openid-test/redirected/yadis/xrds/2', array('absolute' => TRUE));
     $this->addRedirectedIdentity($identity, 2, 'http://example.com/xrds', $expected_claimed_id, 2);
 
     // Fails because there are more than 3 redirects (default value for the
-    // 'max_redirects' option in drupal_http_request()).
+    // 'max_redirects' option in http_request()).
     $identity = url('openid-test/redirected/yadis/xrds/3', array('absolute' => TRUE));
     $expected_claimed_id = FALSE;
     $this->addRedirectedIdentity($identity, 2, 'http://example.com/xrds', $expected_claimed_id, 3);
@@ -600,7 +602,7 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase {
 /**
  * Test internal helper functions.
  */
-class OpenIDUnitTest extends DrupalWebTestCase {
+class OpenIDUnitTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'OpenID helper functions',
diff --git a/core/modules/openid/tests/openid_test.install b/core/modules/openid/tests/openid_test.install
index 3bd4978..b8be889 100644
--- a/core/modules/openid/tests/openid_test.install
+++ b/core/modules/openid/tests/openid_test.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/openid/tests/openid_test.module b/core/modules/openid/tests/openid_test.module
index 11d32b7..32b185c 100644
--- a/core/modules/openid/tests/openid_test.module
+++ b/core/modules/openid/tests/openid_test.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -97,18 +99,18 @@ function openid_test_yadis_xrds() {
     if (arg(3) == 'xri') {
       if (variable_get('clean_url', 0)) {
         if (arg(4) != '@example*résumé;%25' || $_GET['_xrd_r'] != 'application/xrds xml') {
-          drupal_not_found();
+          not_found();
         }
       }
       else {
         // Drupal cannot properly emulate an XRI proxy resolver using unclean
         // URLs, so the arguments gets messed up.
         if (arg(4) . '/' . arg(5) != '@example*résumé;%25?_xrd_r=application/xrds xml') {
-          drupal_not_found();
+          not_found();
         }
       }
     }
-    drupal_add_http_header('Content-Type', 'application/xrds+xml');
+    add_http_header('Content-Type', 'application/xrds+xml');
     print '<?xml version="1.0" encoding="UTF-8"?>
       <xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)" xmlns:openid="http://openid.net/xmlns/1.0">
         <XRD>
@@ -170,7 +172,7 @@ function openid_test_yadis_xrds() {
  * Menu callback; regular HTML page with an X-XRDS-Location HTTP header.
  */
 function openid_test_yadis_x_xrds_location() {
-  drupal_add_http_header('X-XRDS-Location', url('openid-test/yadis/xrds', array('absolute' => TRUE)));
+  add_http_header('X-XRDS-Location', url('openid-test/yadis/xrds', array('absolute' => TRUE)));
   return t('This page includes an X-RDS-Location HTTP header containing the URL of an XRDS document.');
 }
 
@@ -185,7 +187,7 @@ function openid_test_yadis_http_equiv() {
       'content' => url('openid-test/yadis/xrds', array('absolute' => TRUE)),
     ),
   );
-  drupal_add_html_head($element, 'openid_test_yadis_http_equiv');
+  add_html_head($element, 'openid_test_yadis_http_equiv');
   return t('This page includes a &lt;meta equiv=...&gt; element containing the URL of an XRDS document.');
 }
 
@@ -193,8 +195,8 @@ function openid_test_yadis_http_equiv() {
  * Menu callback; regular HTML page with OpenID 1.0 <link> element.
  */
 function openid_test_html_openid1() {
-  drupal_add_html_head_link(array('rel' => 'openid.server', 'href' => url('openid-test/endpoint', array('absolute' => TRUE))));
-  drupal_add_html_head_link(array('rel' => 'openid.delegate', 'href' => 'http://example.com/html-openid1'));
+  add_html_head_link(array('rel' => 'openid.server', 'href' => url('openid-test/endpoint', array('absolute' => TRUE))));
+  add_html_head_link(array('rel' => 'openid.delegate', 'href' => 'http://example.com/html-openid1'));
   return t('This page includes a &lt;link rel=...&gt; element containing the URL of an OpenID Provider Endpoint.');
 }
 
@@ -203,8 +205,8 @@ function openid_test_html_openid1() {
  */
 function openid_test_html_openid2() {
   // Use unusual values in order to test proper parsing of HTML attributes.
-  drupal_add_html_head_link(array('rel' => "foo\nopenid2.PROVIDER\tbar", 'href' => "\n" . url('openid-test/endpoint', array('absolute' => TRUE))));
-  drupal_add_html_head_link(array('rel' => 'openid2.local_id', 'href' => 'http://example.com/html-openid2'));
+  add_html_head_link(array('rel' => "foo\nopenid2.PROVIDER\tbar", 'href' => "\n" . url('openid-test/endpoint', array('absolute' => TRUE))));
+  add_html_head_link(array('rel' => 'openid2.local_id', 'href' => 'http://example.com/html-openid2'));
   return t('This page includes a &lt;link rel=...&gt; element containing the URL of an OpenID Provider Endpoint.');
 }
 
@@ -245,7 +247,7 @@ function openid_test_redirect($count = 0) {
  * Menu callback; respond with appropriate callback.
  */
 function openid_test_redirected_method($method1, $method2) {
-  return call_user_func('openid_test_' . $method1 . '_' . $method2);
+  return call_user_func('Drupal\openid_test_' . $method1 . '_' . $method2);
 }
 
 /**
@@ -256,7 +258,7 @@ function openid_test_redirected_method($method1, $method2) {
  * using Diffie-Hellman key exchange. The MAC key is used in subsequent
  * "authenticate" requests. The "associate" request is made by the Relying Party
  * (in the testing scenario, this is the OpenID module that communicates with
- * the endpoint using drupal_http_request()).
+ * the endpoint using http_request()).
  */
 function _openid_test_endpoint_associate() {
   module_load_include('inc', 'openid');
@@ -294,7 +296,7 @@ function _openid_test_endpoint_associate() {
 
   // Respond to Relying Party in the special Key-Value Form Encoding (see OpenID
   // Authentication 1.0, section 4.1.1).
-  drupal_add_http_header('Content-Type', 'text/plain');
+  add_http_header('Content-Type', 'text/plain');
   print _openid_create_message($response);
 }
 
@@ -317,7 +319,7 @@ function _openid_test_endpoint_authenticate() {
       'openid.mode' => 'error',
       'openid.error' => 'Unexpted identity',
     );
-    drupal_add_http_header('Content-Type', 'text/plain');
+    add_http_header('Content-Type', 'text/plain');
     header('Location: ' . url($_REQUEST['openid_return_to'], array('query' => $response, 'external' => TRUE)));
     return;
   }
@@ -348,7 +350,7 @@ function _openid_test_endpoint_authenticate() {
 
   // Put the signed message into the query string of a URL supplied by the
   // Relying Party, and redirect the user.
-  drupal_add_http_header('Content-Type', 'text/plain');
+  add_http_header('Content-Type', 'text/plain');
   header('Location: ' . url($_REQUEST['openid_return_to'], array('query' => $response, 'external' => TRUE)));
 }
 
diff --git a/core/modules/overlay/overlay.api.php b/core/modules/overlay/overlay.api.php
index bc23546..1c970f0 100644
--- a/core/modules/overlay/overlay.api.php
+++ b/core/modules/overlay/overlay.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -20,7 +21,7 @@
  */
 function hook_overlay_parent_initialize() {
   // Add our custom JavaScript.
-  drupal_add_js(drupal_get_path('module', 'hook') . '/hook-overlay.js');
+  add_js(get_path('module', 'hook') . '/hook-overlay.js');
 }
 
 /**
@@ -32,7 +33,7 @@ function hook_overlay_parent_initialize() {
  */
 function hook_overlay_child_initialize() {
   // Add our custom JavaScript.
-  drupal_add_js(drupal_get_path('module', 'hook') . '/hook-overlay-child.js');
+  add_js(get_path('module', 'hook') . '/hook-overlay-child.js');
 }
 
 /**
diff --git a/core/modules/overlay/overlay.install b/core/modules/overlay/overlay.install
index 2fa7c84..2f21cd7 100644
--- a/core/modules/overlay/overlay.install
+++ b/core/modules/overlay/overlay.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module
index 8f62c01..a47739c 100644
--- a/core/modules/overlay/overlay.module
+++ b/core/modules/overlay/overlay.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -130,20 +131,20 @@ function overlay_init() {
     // <front>#overlay=admin/modules to actually enable the overlay.
     if (isset($_SESSION['overlay_enable_redirect']) && $_SESSION['overlay_enable_redirect']) {
       unset($_SESSION['overlay_enable_redirect']);
-      drupal_goto('<front>', array('fragment' => 'overlay=' . $current_path));
+      redirect('<front>', array('fragment' => 'overlay=' . $current_path));
     }
 
     if (isset($_GET['render']) && $_GET['render'] == 'overlay') {
       // If a previous page requested that we close the overlay, close it and
       // redirect to the final destination.
       if (isset($_SESSION['overlay_close_dialog'])) {
-        call_user_func_array('overlay_close_dialog', $_SESSION['overlay_close_dialog']);
+        call_user_func_array('Drupal\overlay_close_dialog', $_SESSION['overlay_close_dialog']);
         unset($_SESSION['overlay_close_dialog']);
       }
       // If this page shouldn't be rendered inside the overlay, redirect to the
       // parent.
       elseif (!path_is_admin($current_path)) {
-        overlay_close_dialog($current_path, array('query' => drupal_get_query_parameters(NULL, array('q', 'render'))));
+        overlay_close_dialog($current_path, array('query' => get_query_parameters(NULL, array('q', 'render'))));
       }
 
       // Indicate that we are viewing an overlay child page.
@@ -194,7 +195,7 @@ function overlay_exit() {
  * Implements hook_library_info().
  */
 function overlay_library_info() {
-  $module_path = drupal_get_path('module', 'overlay');
+  $module_path = get_path('module', 'overlay');
 
   // Overlay parent.
   $libraries['parent'] = array(
@@ -229,9 +230,9 @@ function overlay_library_info() {
 }
 
 /**
- * Implements hook_drupal_goto_alter().
+ * Implements hook_redirect_alter().
  */
-function overlay_drupal_goto_alter(&$path, &$options, &$http_response_code) {
+function overlay_redirect_alter(&$path, &$options, &$http_response_code) {
   if (overlay_get_mode() == 'child') {
     // The authorize.php script bootstraps Drupal to a very low level, where
     // the PHP code that is necessary to close the overlay properly will not be
@@ -242,7 +243,7 @@ function overlay_drupal_goto_alter(&$path, &$options, &$http_response_code) {
     if ($path == system_authorized_get_url() || $path == system_authorized_batch_processing_url()) {
       $_SESSION['overlay_close_dialog'] = array($path, $options);
       $path = current_path();
-      $options = drupal_get_query_parameters();
+      $options = get_query_parameters();
     }
 
     // If the current page request is inside the overlay, add ?render=overlay
@@ -307,14 +308,14 @@ function overlay_user_dismiss_message() {
   // the anonymous role. In this case, we do not display the message to disable
   // the overlay, so there is nothing to dismiss. Also, protect against
   // cross-site request forgeries by validating a token.
-  if (empty($user->uid) || !isset($_GET['token']) || !drupal_valid_token($_GET['token'], 'overlay')) {
+  if (empty($user->uid) || !isset($_GET['token']) || !valid_token($_GET['token'], 'overlay')) {
     return MENU_ACCESS_DENIED;
   }
   else {
     user_save(user_load($user->uid), array('data' => array('overlay_message_dismissed' => 1)));
-    drupal_set_message(t('The message has been dismissed. You can change your overlay settings at any time by visiting your profile page.'));
+    set_message(t('The message has been dismissed. You can change your overlay settings at any time by visiting your profile page.'));
     // Destination is normally given. Go to the user profile as a fallback.
-    drupal_goto('user/' . $user->uid . '/edit');
+    redirect('user/' . $user->uid . '/edit');
   }
 }
 
@@ -342,7 +343,7 @@ function overlay_disable_message() {
         '#title' => t('If you have problems accessing administrative pages on this site, disable the overlay on your profile page.'),
         '#href' => 'user/' . $user->uid . '/edit',
         '#options' => array(
-          'query' => drupal_get_destination(),
+          'query' => get_destination(),
           'fragment' => 'edit-overlay-control',
           'attributes' => array(
             'id' => 'overlay-profile-link',
@@ -358,9 +359,9 @@ function overlay_disable_message() {
         '#title' => t('Dismiss this message.'),
         '#href' => 'overlay/dismiss-message',
         '#options' => array(
-          'query' => drupal_get_destination() + array(
+          'query' => get_destination() + array(
             // Add a token to protect against cross-site request forgeries.
-            'token' => drupal_get_token('overlay'),
+            'token' => get_token('overlay'),
           ),
           'attributes' => array(
             'id' => 'overlay-dismiss-message',
@@ -476,7 +477,7 @@ function overlay_preprocess_maintenance_page(&$variables) {
  */
 function template_preprocess_overlay(&$variables) {
   $variables['tabs'] = menu_primary_local_tasks();
-  $variables['title'] = drupal_get_title();
+  $variables['title'] = get_title();
   $variables['disable_overlay'] = overlay_disable_message();
   $variables['content_attributes_array']['class'][] = 'clearfix';
 }
@@ -553,7 +554,7 @@ function overlay_page_delivery_callback_alter(&$callback) {
  * the scripts and styles necessary in order to trigger the overlay to close.
  */
 function overlay_deliver_empty_page() {
-  $empty_page = '<html><head><title></title>' . drupal_get_css() . drupal_get_js() . '</head><body class="overlay"></body></html>';
+  $empty_page = '<html><head><title></title>' . get_css() . get_js() . '</head><body class="overlay"></body></html>';
   print $empty_page;
   drupal_exit();
 }
@@ -612,14 +613,14 @@ function overlay_set_mode($mode = NULL) {
 
   switch ($overlay_mode) {
     case 'parent':
-      drupal_add_library('overlay', 'parent');
+      add_library('overlay', 'parent');
 
       // Allow modules to act upon overlay events.
       module_invoke_all('overlay_parent_initialize');
       break;
 
     case 'child':
-      drupal_add_library('overlay', 'child');
+      add_library('overlay', 'child');
 
       // Allow modules to act upon overlay events.
       module_invoke_all('overlay_child_initialize');
@@ -637,9 +638,9 @@ function overlay_overlay_parent_initialize() {
   foreach ($paths as &$type) {
     $type = str_replace('<front>', variable_get('site_frontpage', 'user'), $type);
   }
-  drupal_add_js(array('overlay' => array('paths' => $paths)), 'setting');
+  add_js(array('overlay' => array('paths' => $paths)), 'setting');
   // Pass along the Ajax callback for rerendering sections of the parent window.
-  drupal_add_js(array('overlay' => array('ajaxCallback' => 'overlay-ajax')), 'setting');
+  add_js(array('overlay' => array('ajaxCallback' => 'overlay-ajax')), 'setting');
 }
 
 /**
@@ -693,7 +694,7 @@ function overlay_close_dialog($redirect = NULL, $redirect_options = array()) {
     $settings['overlayChild']['redirect'] = url($redirect, $redirect_options);
   }
 
-  drupal_add_js($settings, array('type' => 'setting'));
+  add_js($settings, array('type' => 'setting'));
 
   // Since we are closing the overlay as soon as the page is displayed, we do
   // not want to show any of the page's actual content.
@@ -756,7 +757,7 @@ function overlay_supplemental_regions() {
 function _overlay_region_list($type) {
   // Obtain the current theme. We need to first make sure the theme system is
   // initialized, since this function can be called early in the page request.
-  drupal_theme_initialize();
+  theme_initialize();
   $themes = list_themes();
   $theme = $themes[$GLOBALS['theme']];
   // Return the list of regions stored within the theme's info array, or an
@@ -769,7 +770,7 @@ function _overlay_region_list($type) {
  *
  * @return
  *   An array containing the names of the regions that will be rendered when
- *   drupal_render_page() is called. If empty, then no limits will be imposed,
+ *   render_page() is called. If empty, then no limits will be imposed,
  *   and all regions of the page will be rendered.
  *
  * @see overlay_page_alter()
@@ -785,8 +786,8 @@ function overlay_get_regions_to_render() {
  *
  * @param $regions
  *   (Optional) An array containing the names of the regions that should be
- *   rendered when drupal_render_page() is called. Pass in an empty array to
- *   remove all limits and cause drupal_render_page() to render all page
+ *   rendered when render_page() is called. Pass in an empty array to
+ *   remove all limits and cause render_page() to render all page
  *   regions (the default behavior). If this parameter is omitted, no change
  *   will be made to the current list of regions to render.
  *
@@ -827,7 +828,7 @@ function overlay_render_region($region) {
   // Indicate the region that we will be rendering, so that other regions will
   // be hidden by overlay_page_alter() and overlay_block_list_alter().
   overlay_set_regions_to_render(array($region));
-  // Do what is necessary to force drupal_render_page() to only display HTML
+  // Do what is necessary to force render_page() to only display HTML
   // from the requested region. Specifically, declare that the main page
   // content does not need to automatically be added to the page, and pass in
   // a page array that has all theme functions removed (so that overall HTML
@@ -840,25 +841,25 @@ function overlay_render_region($region) {
     '#theme_wrappers' => array(),
   );
   // Render the region, but do not cache any JavaScript or CSS associated with
-  // it. This region might not be included the next time drupal_render_page()
+  // it. This region might not be included the next time render_page()
   // is called, and we do not want its JavaScript or CSS to erroneously appear
   // on the final rendered page.
-  $original_js = drupal_add_js();
-  $original_css = drupal_add_css();
-  $original_libraries = drupal_static('drupal_add_library');
-  $js = &drupal_static('drupal_add_js');
-  $css = &drupal_static('drupal_add_css');
-  $libraries = &drupal_static('drupal_add_library');
-  $markup = drupal_render_page($page);
+  $original_js = add_js();
+  $original_css = add_css();
+  $original_libraries = drupal_static('Drupal\add_library');
+  $js = &drupal_static('Drupal\add_js');
+  $css = &drupal_static('Drupal\add_css');
+  $libraries = &drupal_static('Drupal\add_library');
+  $markup = render_page($page);
   $js = $original_js;
   $css = $original_css;
   $libraries = $original_libraries;
   // Indicate that the main page content has not, in fact, been displayed, so
-  // that future calls to drupal_render_page() will be able to render it
+  // that future calls to render_page() will be able to render it
   // correctly.
   $system_main_content_added = FALSE;
   // Restore the original behavior of rendering all regions for the next time
-  // drupal_render_page() is called.
+  // render_page() is called.
   overlay_set_regions_to_render(array());
   return $markup;
 }
@@ -916,7 +917,7 @@ function overlay_store_rendered_content($id = NULL, $content = NULL) {
  * @see Drupal.overlay.refreshRegions()
  */
 function overlay_request_refresh($region) {
-  $class = drupal_region_class($region);
+  $class = region_class($region);
   $_SESSION['overlay_regions_to_refresh'][] = array($class => $region);
 }
 
@@ -948,11 +949,11 @@ function overlay_trigger_refresh() {
         'refreshRegions' => $_SESSION['overlay_regions_to_refresh'],
       ),
     );
-    drupal_add_js($settings, array('type' => 'setting'));
+    add_js($settings, array('type' => 'setting'));
     unset($_SESSION['overlay_regions_to_refresh']);
   }
   if (!empty($_SESSION['overlay_refresh_parent'])) {
-    drupal_add_js(array('overlayChild' => array('refreshPage' => TRUE)), array('type' => 'setting'));
+    add_js(array('overlayChild' => array('refreshPage' => TRUE)), array('type' => 'setting'));
     unset($_SESSION['overlay_refresh_parent']);
   }
 }
diff --git a/core/modules/overlay/overlay.tpl.php b/core/modules/overlay/overlay.tpl.php
index 54b10af..ced115d 100644
--- a/core/modules/overlay/overlay.tpl.php
+++ b/core/modules/overlay/overlay.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/path/path.admin.inc b/core/modules/path/path.admin.inc
index 4bca34a..e7f0d55 100644
--- a/core/modules/path/path.admin.inc
+++ b/core/modules/path/path.admin.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use PDO;
 
 /**
  * @file
@@ -13,7 +15,7 @@
  */
 function path_admin_overview($keys = NULL) {
   // Add the filter form above the overview table.
-  $build['path_admin_filter_form'] = drupal_get_form('path_admin_filter_form', $keys);
+  $build['path_admin_filter_form'] = get_form('path_admin_filter_form', $keys);
   // Enable language column if locale is enabled or if we have any alias with language
   $alias_exists = (bool) db_query_range('SELECT 1 FROM {url_alias} WHERE langcode <> :langcode', 0, 1, array(':langcode' => LANGUAGE_NONE))->fetchField();
   $multilanguage = (module_exists('locale') || $alias_exists);
@@ -38,7 +40,7 @@ function path_admin_overview($keys = NULL) {
     ->execute();
 
   $rows = array();
-  $destination = drupal_get_destination();
+  $destination = get_destination();
   foreach ($result as $data) {
     $row = array();
     $row['data']['alias'] = l($data->alias, $data->source);
@@ -68,7 +70,7 @@ function path_admin_overview($keys = NULL) {
 
     // If the system path maps to a different URL alias, highlight this table
     // row to let the user know of old aliases.
-    if ($data->alias != drupal_get_path_alias($data->source, $data->langcode)) {
+    if ($data->alias != get_path_alias($data->source, $data->langcode)) {
       $row['class'] = array('warning');
     }
 
@@ -91,11 +93,11 @@ function path_admin_overview($keys = NULL) {
  */
 function path_admin_edit($path = array()) {
   if ($path) {
-    drupal_set_title($path['alias']);
-    $output = drupal_get_form('path_admin_form', $path);
+    set_title($path['alias']);
+    $output = get_form('path_admin_form', $path);
   }
   else {
-    $output = drupal_get_form('path_admin_form');
+    $output = get_form('path_admin_form');
   }
 
   return $output;
@@ -180,7 +182,7 @@ function path_admin_form($form, &$form_state, $path = array('source' => '', 'ali
 function path_admin_form_delete_submit($form, &$form_state) {
   $destination = array();
   if (isset($_GET['destination'])) {
-    $destination = drupal_get_destination();
+    $destination = get_destination();
     unset($_GET['destination']);
   }
   $form_state['redirect'] = array('admin/config/search/path/delete/' . $form_state['values']['pid'], array('query' => $destination));
@@ -191,7 +193,7 @@ function path_admin_form_delete_submit($form, &$form_state) {
  */
 function path_admin_form_validate($form, &$form_state) {
   $source = &$form_state['values']['source'];
-  $source = drupal_get_normal_path($source);
+  $source = get_normal_path($source);
   $alias = $form_state['values']['alias'];
   $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0;
   // Language is only set if locale module is enabled, otherwise save for all languages.
@@ -207,7 +209,7 @@ function path_admin_form_validate($form, &$form_state) {
   if ($has_alias) {
     form_set_error('alias', t('The alias %alias is already in use in this language.', array('%alias' => $alias)));
   }
-  if (!drupal_valid_path($source)) {
+  if (!valid_path($source)) {
     form_set_error('source', t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $source)));
   }
 }
@@ -221,7 +223,7 @@ function path_admin_form_submit($form, &$form_state) {
 
   path_save($form_state['values']);
 
-  drupal_set_message(t('The alias has been saved.'));
+  set_message(t('The alias has been saved.'));
   $form_state['redirect'] = 'admin/config/search/path';
 }
 
diff --git a/core/modules/path/path.api.php b/core/modules/path/path.api.php
index 1df7ee5..994c169 100644
--- a/core/modules/path/path.api.php
+++ b/core/modules/path/path.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/path/path.module b/core/modules/path/path.module
index 9d7b2b1..a0df080 100644
--- a/core/modules/path/path.module
+++ b/core/modules/path/path.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -69,7 +70,7 @@ function path_menu() {
   );
   $items['admin/config/search/path/delete/%path'] = array(
     'title' => 'Delete alias',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('path_admin_delete_confirm', 5),
     'access arguments' => array('administer url aliases'),
     'file' => 'path.admin.inc',
@@ -122,7 +123,7 @@ function path_form_node_form_alter(&$form, $form_state) {
       'class' => array('path-form'),
     ),
     '#attached' => array(
-      'js' => array(drupal_get_path('module', 'path') . '/path.js'),
+      'js' => array(get_path('module', 'path') . '/path.js'),
     ),
     '#access' => user_access('create url aliases') || user_access('administer url aliases'),
     '#weight' => 30,
diff --git a/core/modules/path/path.test b/core/modules/path/path.test
index d5a18d3..afbfc3e 100644
--- a/core/modules/path/path.test
+++ b/core/modules/path/path.test
@@ -1,11 +1,12 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
  * Tests for path.module.
  */
 
-class PathTestCase extends DrupalWebTestCase {
+class PathTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Path alias functionality',
@@ -79,7 +80,7 @@ class PathTestCase extends DrupalWebTestCase {
     $this->assertText($node1->title, 'Changed alias works.');
     $this->assertResponse(200);
 
-    drupal_static_reset('drupal_lookup_path');
+    drupal_static_reset('Drupal\lookup_path');
     // Confirm that previous alias no longer works.
     $this->drupalGet($previous);
     $this->assertNoText($node1->title, 'Previous alias no longer works.');
@@ -167,7 +168,7 @@ class PathTestCase extends DrupalWebTestCase {
 /**
  * Test URL aliases for taxonomy terms.
  */
-class PathTaxonomyTermTestCase extends DrupalWebTestCase {
+class PathTaxonomyTermTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Taxonomy term URL aliases',
@@ -228,7 +229,7 @@ class PathTaxonomyTermTestCase extends DrupalWebTestCase {
   }
 }
 
-class PathLanguageTestCase extends DrupalWebTestCase {
+class PathLanguageTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Path aliases with translated nodes',
@@ -287,7 +288,7 @@ class PathLanguageTestCase extends DrupalWebTestCase {
     $this->drupalPost(NULL, $edit, t('Save'));
 
     // Clear the path lookup cache.
-    drupal_lookup_path('wipe');
+    lookup_path('wipe');
 
     // Ensure the node was created.
     $french_node = $this->drupalGetNodeByTitle($edit["title"]);
@@ -299,9 +300,9 @@ class PathLanguageTestCase extends DrupalWebTestCase {
 
     // Confirm that the alias is returned by url(). Languages are cached on
     // many levels, and we need to clear those caches.
-    drupal_static_reset('language_list');
-    drupal_static_reset('locale_url_outbound_alter');
-    drupal_static_reset('locale_language_url_rewrite_url');
+    drupal_static_reset('Drupal\language_list');
+    drupal_static_reset('Drupal\locale_url_outbound_alter');
+    drupal_static_reset('Drupal\locale_language_url_rewrite_url');
     $languages = language_list();
     $url = url('node/' . $french_node->nid, array('language' => $languages[$french_node->language]));
     $this->assertTrue(strpos($url, $edit['path[alias]']), t('URL contains the path alias.'));
@@ -326,7 +327,7 @@ class PathLanguageTestCase extends DrupalWebTestCase {
     // We need to ensure that the user language preference is not taken into
     // account while determining the path alias language, because if this
     // happens we have no way to check that the path alias is valid: there is no
-    // path alias for French matching the english alias. So drupal_lookup_path()
+    // path alias for French matching the english alias. So lookup_path()
     // needs to use the URL language to check whether the alias is valid.
     $this->drupalGet($english_alias);
     $this->assertText($english_node->title, 'Alias for English translation works.');
@@ -350,20 +351,20 @@ class PathLanguageTestCase extends DrupalWebTestCase {
     $this->drupalGet($french_alias);
     $this->assertResponse(404, t('Alias for French translation is unavailable when URL language negotiation is disabled.'));
 
-    // drupal_lookup_path() has an internal static cache. Check to see that
+    // lookup_path() has an internal static cache. Check to see that
     // it has the appropriate contents at this point.
-    drupal_lookup_path('wipe');
-    $french_node_path = drupal_lookup_path('source', $french_alias, $french_node->language);
+    lookup_path('wipe');
+    $french_node_path = lookup_path('source', $french_alias, $french_node->language);
     $this->assertEqual($french_node_path, 'node/' . $french_node->nid, t('Normal path works.'));
     // Second call should return the same path.
-    $french_node_path = drupal_lookup_path('source', $french_alias, $french_node->language);
+    $french_node_path = lookup_path('source', $french_alias, $french_node->language);
     $this->assertEqual($french_node_path, 'node/' . $french_node->nid, t('Normal path is the same.'));
 
     // Confirm that the alias works.
-    $french_node_alias = drupal_lookup_path('alias', 'node/' . $french_node->nid, $french_node->language);
+    $french_node_alias = lookup_path('alias', 'node/' . $french_node->nid, $french_node->language);
     $this->assertEqual($french_node_alias, $french_alias, t('Alias works.'));
     // Second call should return the same alias.
-    $french_node_alias = drupal_lookup_path('alias', 'node/' . $french_node->nid, $french_node->language);
+    $french_node_alias = lookup_path('alias', 'node/' . $french_node->nid, $french_node->language);
     $this->assertEqual($french_node_alias, $french_alias, t('Alias is the same.'));
   }
 }
@@ -371,7 +372,7 @@ class PathLanguageTestCase extends DrupalWebTestCase {
 /**
  * Tests the user interface for creating path aliases, with languages.
  */
-class PathLanguageUITestCase extends DrupalWebTestCase {
+class PathLanguageUITestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Path aliases with languages',
@@ -447,7 +448,7 @@ class PathLanguageUITestCase extends DrupalWebTestCase {
 /**
  * Tests that paths are not prefixed on a monolingual site.
  */
-class PathMonolingualTestCase extends DrupalWebTestCase {
+class PathMonolingualTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Paths on non-English monolingual sites',
@@ -486,7 +487,7 @@ class PathMonolingualTestCase extends DrupalWebTestCase {
     $this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
 
     // Force languages to be initialized.
-    drupal_language_initialize();
+    language_initialize();
   }
 
   /**
diff --git a/core/modules/php/php.install b/core/modules/php/php.install
index 12944dd..99f1c37 100644
--- a/core/modules/php/php.install
+++ b/core/modules/php/php.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -33,7 +34,7 @@ function php_enable() {
     $php_format = (object) $php_format;
     filter_format_save($php_format);
 
-    drupal_set_message(t('A <a href="@php-code">PHP code</a> text format has been created.', array('@php-code' => url('admin/config/content/formats/' . $php_format->format))));
+    set_message(t('A <a href="@php-code">PHP code</a> text format has been created.', array('@php-code' => url('admin/config/content/formats/' . $php_format->format))));
   }
 }
 
@@ -41,5 +42,5 @@ function php_enable() {
  * Implements hook_disable().
  */
 function php_disable() {
-  drupal_set_message(t('The PHP module has been disabled. Any existing content that was using the PHP filter will now be visible in plain text. This might pose a security risk by exposing sensitive information, if any, used in the PHP code.'));
+  set_message(t('The PHP module has been disabled. Any existing content that was using the PHP filter will now be visible in plain text. This might pose a security risk by exposing sensitive information, if any, used in the PHP code.'));
 }
diff --git a/core/modules/php/php.module b/core/modules/php/php.module
index 1fb91c1..c2b18e3 100644
--- a/core/modules/php/php.module
+++ b/core/modules/php/php.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -70,7 +71,7 @@ function php_eval($code) {
   // so code evaluated will not see the caller module as the current theme.
   // If theme info is not initialized get the path from theme_default.
   if (!isset($theme_info)) {
-    $theme_path = drupal_get_path('theme', $conf['theme_default']);
+    $theme_path = get_path('theme', $conf['theme_default']);
   }
   else {
     $theme_path = dirname($theme_info->filename);
diff --git a/core/modules/php/php.test b/core/modules/php/php.test
index 50fb552..46975dd 100644
--- a/core/modules/php/php.test
+++ b/core/modules/php/php.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -8,7 +9,7 @@
 /**
  * Defines a base PHP test case class.
  */
-class PHPTestCase extends DrupalWebTestCase {
+class PHPTestCase extends WebTestCase {
   protected $php_code_format;
 
   function setUp() {
diff --git a/core/modules/poll/poll-bar--block.tpl.php b/core/modules/poll/poll-bar--block.tpl.php
index 3b91afc..04796bc 100644
--- a/core/modules/poll/poll-bar--block.tpl.php
+++ b/core/modules/poll/poll-bar--block.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/poll/poll-bar.tpl.php b/core/modules/poll/poll-bar.tpl.php
index 9426ff5..383b465 100644
--- a/core/modules/poll/poll-bar.tpl.php
+++ b/core/modules/poll/poll-bar.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/poll/poll-results--block.tpl.php b/core/modules/poll/poll-results--block.tpl.php
index f8387f5..aba0614 100644
--- a/core/modules/poll/poll-results--block.tpl.php
+++ b/core/modules/poll/poll-results--block.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 /**
  * @file
  * Default theme implementation to display the poll results in a block.
diff --git a/core/modules/poll/poll-results.tpl.php b/core/modules/poll/poll-results.tpl.php
index 5e14dec..9dac22b 100644
--- a/core/modules/poll/poll-results.tpl.php
+++ b/core/modules/poll/poll-results.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/poll/poll-vote.tpl.php b/core/modules/poll/poll-vote.tpl.php
index 068ff7c..03e8a4b 100644
--- a/core/modules/poll/poll-vote.tpl.php
+++ b/core/modules/poll/poll-vote.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/poll/poll.install b/core/modules/poll/poll.install
index c848445..133a993 100644
--- a/core/modules/poll/poll.install
+++ b/core/modules/poll/poll.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/poll/poll.module b/core/modules/poll/poll.module
index 40a481a..59e26d5 100644
--- a/core/modules/poll/poll.module
+++ b/core/modules/poll/poll.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use PDO, stdClass;
 
 /**
  * @file
@@ -321,7 +323,7 @@ function poll_form($node, &$form_state) {
     // 1 year (365 days).
     31536000,
   );
-  $duration = array(0 => t('Unlimited')) + drupal_map_assoc($duration, 'format_interval');
+  $duration = array(0 => t('Unlimited')) + map_assoc($duration, 'format_interval');
   $active = array(0 => t('Closed'), 1 => t('Active'));
 
   $form['settings'] = array(
@@ -651,7 +653,7 @@ function poll_block_latest_poll_view($node) {
   $node->links = $links;
 
   if (!empty($node->allowvotes)) {
-    $node->content['poll_view_voting'] = drupal_get_form('poll_view_voting', $node, TRUE);
+    $node->content['poll_view_voting'] = get_form('poll_view_voting', $node, TRUE);
     $node->content['links'] = array(
       '#theme' => 'links',
       '#links' => $node->links,
@@ -674,7 +676,7 @@ function poll_view($node, $view_mode) {
   $output = '';
 
   if (!empty($node->allowvotes) && empty($node->show_results)) {
-    $node->content['poll_view_voting'] = drupal_get_form('poll_view_voting', $node);
+    $node->content['poll_view_voting'] = get_form('poll_view_voting', $node);
   }
   else {
     $node->content['poll_view_results'] = array('#markup' => poll_view_results($node, $view_mode));
@@ -784,7 +786,7 @@ function poll_vote($form, &$form_state) {
     $_SESSION['poll_vote'][$node->nid] = $choice;
   }
 
-  drupal_set_message(t('Your vote was recorded.'));
+  set_message(t('Your vote was recorded.'));
 
   // Return the user to whatever page they voted from.
 }
@@ -808,7 +810,7 @@ function template_preprocess_poll_vote(&$variables) {
   $variables['choice'] = drupal_render($form['choice']);
   $variables['title'] = check_plain($form['#node']->title);
   $variables['vote'] = drupal_render($form['vote']);
-  $variables['rest'] = drupal_render_children($form);
+  $variables['rest'] = render_children($form);
   $variables['block'] = $form['#block'];
   if ($variables['block']) {
     $variables['theme_hook_suggestions'][] = 'poll_vote__block';
@@ -820,7 +822,7 @@ function template_preprocess_poll_vote(&$variables) {
  */
 function poll_view_results($node, $view_mode, $block = FALSE) {
   // Make sure that choices are ordered by their weight.
-  uasort($node->choice, 'drupal_sort_weight');
+  uasort($node->choice, 'Drupal\sort_weight');
 
   // Count the votes and find the maximum
   $total_votes = 0;
@@ -856,7 +858,7 @@ function poll_view_results($node, $view_mode, $block = FALSE) {
 function theme_poll_choices($variables) {
   $form = $variables['form'];
 
-  drupal_add_tabledrag('poll-choice-table', 'order', 'sibling', 'poll-weight');
+  add_tabledrag('poll-choice-table', 'order', 'sibling', 'poll-weight');
 
   $is_admin= user_access('administer nodes');
   $delta = 0;
@@ -894,7 +896,7 @@ function theme_poll_choices($variables) {
   }
 
   $output = theme('table', array('header' => $headers, 'rows' => $rows, 'attributes' => array('id' => 'poll-choice-table')));
-  $output .= drupal_render_children($form);
+  $output .= render_children($form);
   return $output;
 }
 
@@ -913,7 +915,7 @@ function theme_poll_choices($variables) {
 function template_preprocess_poll_results(&$variables) {
   $variables['links'] = theme('links__poll_results', array('links' => $variables['raw_links']));
   if (isset($variables['vote']) && $variables['vote'] > -1 && user_access('cancel own vote')) {
-    $elements = drupal_get_form('poll_cancel_form', $variables['nid']);
+    $elements = get_form('poll_cancel_form', $variables['nid']);
     $variables['cancel_form'] = drupal_render($elements);
   }
   $variables['title'] = check_plain($variables['raw_title']);
@@ -982,7 +984,7 @@ function poll_cancel($form, &$form_state) {
 
   unset($_SESSION['poll_vote'][$node->nid]);
 
-  drupal_set_message(t('Your vote was cancelled.'));
+  set_message(t('Your vote was cancelled.'));
 }
 
 /**
diff --git a/core/modules/poll/poll.pages.inc b/core/modules/poll/poll.pages.inc
index 15f3ba7..5cf8cb7 100644
--- a/core/modules/poll/poll.pages.inc
+++ b/core/modules/poll/poll.pages.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -50,7 +51,7 @@ function poll_page() {
  */
 function poll_votes($node) {
   $votes_per_page = 20;
-  drupal_set_title($node->title);
+  set_title($node->title);
 
   $header[] = array('data' => t('Visitor'), 'field' => 'u.name');
   $header[] = array('data' => t('Vote'), 'field' => 'pc.chtext');
@@ -91,7 +92,7 @@ function poll_votes($node) {
  * Callback for the 'results' tab for polls you can vote on
  */
 function poll_results($node) {
-  drupal_set_title($node->title);
+  set_title($node->title);
   $node->show_results = TRUE;
   return node_show($node);
 }
diff --git a/core/modules/poll/poll.test b/core/modules/poll/poll.test
index 3fad677..32456aa 100644
--- a/core/modules/poll/poll.test
+++ b/core/modules/poll/poll.test
@@ -1,11 +1,12 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
  * Tests for poll.module.
  */
 
-class PollTestCase extends DrupalWebTestCase {
+class PollTestCase extends WebTestCase {
 
   /**
    * Creates a poll.
@@ -84,7 +85,7 @@ class PollTestCase extends DrupalWebTestCase {
    * @return
    *   An indexed array containing:
    *   - The generated POST values, suitable for
-   *     DrupalWebTestCase::drupalPost().
+   *     WebTestCase::drupalPost().
    *   - The number of poll choices contained in 'edit', for potential re-usage
    *     in subsequent invocations of this function.
    */
@@ -433,7 +434,7 @@ class PollBlockTestCase extends PollTestCase {
 /**
  * Test adding new choices.
  */
-class PollJSAddChoice extends DrupalWebTestCase {
+class PollJSAddChoice extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -488,7 +489,7 @@ class PollVoteCheckHostname extends PollTestCase {
     $this->drupalLogin($this->admin_user);
 
     // Allow anonymous users to vote on polls.
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(ANONYMOUS_RID, array(
       'access content' => TRUE,
       'vote on polls' => TRUE,
       'cancel own vote' => TRUE,
@@ -741,7 +742,7 @@ class PollExpirationTestCase extends PollTestCase {
 
     // Force a cron run. Since the expiration date has not yet been reached,
     // the poll should remain active.
-    drupal_cron_run();
+    cron_run();
     $this->drupalGet("node/$poll_nid/edit");
     $elements = $this->xpath('//input[@id="edit-active-1"]');
     $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), t('Poll is still active.'));
@@ -756,7 +757,7 @@ class PollExpirationTestCase extends PollTestCase {
       ->execute();
 
     // Run cron and verify that the poll is now marked as "closed".
-    drupal_cron_run();
+    cron_run();
     $this->drupalGet("node/$poll_nid/edit");
     $elements = $this->xpath('//input[@id="edit-active-0"]');
     $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), t('Poll has expired.'));
diff --git a/core/modules/poll/poll.tokens.inc b/core/modules/poll/poll.tokens.inc
index 4226a69..36d43b8 100644
--- a/core/modules/poll/poll.tokens.inc
+++ b/core/modules/poll/poll.tokens.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/rdf/rdf.api.php b/core/modules/rdf/rdf.api.php
index b3f95ba..a9f417e 100644
--- a/core/modules/rdf/rdf.api.php
+++ b/core/modules/rdf/rdf.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/rdf/rdf.install b/core/modules/rdf/rdf.install
index 10d3f8d..21ec106 100644
--- a/core/modules/rdf/rdf.install
+++ b/core/modules/rdf/rdf.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module
index 1e1485e..a6fec19 100644
--- a/core/modules/rdf/rdf.module
+++ b/core/modules/rdf/rdf.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -265,7 +266,7 @@ function rdf_mapping_delete($type, $bundle) {
 
 /**
  * Builds an array of RDFa attributes for a given mapping. This array will
- * typically be passed through drupal_attributes() to create the attributes
+ * typically be passed through attributes() to create the attributes
  * variables that are available to template files. These include $attributes,
  * $title_attributes, $content_attributes and the field-specific
  * $item_attributes variables. For more information, see
@@ -286,7 +287,7 @@ function rdf_mapping_delete($type, $bundle) {
  *   A value that needs to be converted by the provided callback function.
  *
  * @return
- *   An array containing RDFa attributes suitable for drupal_attributes().
+ *   An array containing RDFa attributes suitable for attributes().
  */
 function rdf_rdfa_attributes($mapping, $data = NULL) {
   // The type of mapping defaults to 'property'.
@@ -305,7 +306,7 @@ function rdf_rdfa_attributes($mapping, $data = NULL) {
       $attributes['property'] = $mapping['predicates'];
       // Convert $data to a specific format as per the callback function.
       if (isset($data) && isset($mapping['callback'])) {
-        $callback = $mapping['callback'];
+        $callback = 'Drupal\\' . $mapping['callback'];
         $attributes['content'] = $callback($data);
       }
       if (isset($mapping['datatype'])) {
@@ -335,7 +336,7 @@ function rdf_rdfa_attributes($mapping, $data = NULL) {
  */
 function rdf_modules_installed($modules) {
   foreach ($modules as $module) {
-    $function = $module . '_rdf_mapping';
+    $function = 'Drupal\\' . $module . '_rdf_mapping';
     if (function_exists($function)) {
       foreach ($function() as $mapping) {
         // Only the bundle mappings are saved in the database.
@@ -503,7 +504,7 @@ function rdf_preprocess_node(&$variables) {
     if (!empty($variables['node']->rdf_mapping['title']['predicates'])) {
       $element['#attributes']['property'] = $variables['node']->rdf_mapping['title']['predicates'];
     }
-    drupal_add_html_head($element, 'rdf_node_title');
+    add_html_head($element, 'rdf_node_title');
   }
 
   // Adds RDFa markup for the date.
@@ -550,7 +551,7 @@ function rdf_preprocess_node(&$variables) {
           'datatype' => $variables['node']->rdf_mapping['comment_count']['datatype'],
         ),
       );
-      drupal_add_html_head($element, 'rdf_node_comment_count');
+      add_html_head($element, 'rdf_node_comment_count');
     }
   }
 }
@@ -616,8 +617,8 @@ function rdf_preprocess_user_profile(&$variables) {
       'content' => $account->name,
     )
   );
-  drupal_add_html_head($account_holder_meta, 'rdf_user_account_holder');
-  drupal_add_html_head($username_meta, 'rdf_user_username');
+  add_html_head($account_holder_meta, 'rdf_user_account_holder');
+  add_html_head($username_meta, 'rdf_user_username');
 }
 
 /**
@@ -748,7 +749,7 @@ function rdf_preprocess_taxonomy_term(&$variables) {
         'content' => $term->name,
       ),
     );
-  drupal_add_html_head($term_label_meta, 'rdf_term_label');
+  add_html_head($term_label_meta, 'rdf_term_label');
 }
 
 /**
@@ -805,7 +806,7 @@ function rdf_preprocess_image(&$variables) {
  * an extra wrapper element, you can override this function to not wrap that
  * variable and instead print the following inside your template file:
  * @code
- *   drupal_attributes($rdf_template_variable_attributes_array[$variable_name])
+ *   attributes($rdf_template_variable_attributes_array[$variable_name])
  * @endcode
  *
  * @param $variables
@@ -843,7 +844,7 @@ function rdf_preprocess_image(&$variables) {
 function theme_rdf_template_variable_wrapper($variables) {
   $output = $variables['content'];
   if (!empty($output) && !empty($variables['attributes'])) {
-    $attributes = drupal_attributes($variables['attributes']);
+    $attributes = attributes($variables['attributes']);
     $output = $variables['inline'] ? "<span$attributes>$output</span>" : "<div$attributes>$output</div>";
   }
   return $output;
@@ -879,7 +880,7 @@ function theme_rdf_metadata($variables) {
     // be used, but for maximum browser compatibility, W3C recommends the
     // former when serving pages using the text/html media type, see
     // http://www.w3.org/TR/xhtml1/#C_3.
-    $output .= '<span' . drupal_attributes($attributes) . '></span>';
+    $output .= '<span' . attributes($attributes) . '></span>';
   }
   return $output;
 }
diff --git a/core/modules/rdf/rdf.test b/core/modules/rdf/rdf.test
index 1344ded..bdbf2f3 100644
--- a/core/modules/rdf/rdf.test
+++ b/core/modules/rdf/rdf.test
@@ -1,11 +1,12 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
  * Tests for rdf.module.
  */
 
-class RdfMappingHookTestCase extends DrupalWebTestCase {
+class RdfMappingHookTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'RDF mapping hook',
@@ -41,7 +42,7 @@ class RdfMappingHookTestCase extends DrupalWebTestCase {
 /**
  * Test RDFa markup generation.
  */
-class RdfRdfaMarkupTestCase extends DrupalWebTestCase {
+class RdfRdfaMarkupTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'RDFa markup',
@@ -208,7 +209,7 @@ class RdfRdfaMarkupTestCase extends DrupalWebTestCase {
   }
 }
 
-class RdfCrudTestCase extends DrupalWebTestCase {
+class RdfCrudTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'RDF mapping CRUD functions',
@@ -426,14 +427,14 @@ class RdfCommentAttributesTestCase extends CommentHelperCase {
     $this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'create article content', 'access user profiles'));
 
     // Enables anonymous user comments.
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(ANONYMOUS_RID, array(
       'access comments' => TRUE,
       'post comments' => TRUE,
       'skip comment approval' => TRUE,
     ));
     // Allows anonymous to leave their contact information.
     $this->setCommentAnonymous(COMMENT_ANONYMOUS_MAY_CONTACT);
-    $this->setCommentPreview(DRUPAL_OPTIONAL);
+    $this->setCommentPreview(OPTIONAL);
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(TRUE);
     $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
@@ -572,7 +573,7 @@ class RdfCommentAttributesTestCase extends CommentHelperCase {
   }
 }
 
-class RdfTrackerAttributesTestCase extends DrupalWebTestCase {
+class RdfTrackerAttributesTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'RDF tracker page mapping',
@@ -584,7 +585,7 @@ class RdfTrackerAttributesTestCase extends DrupalWebTestCase {
   function setUp() {
     parent::setUp('rdf', 'rdf_test', 'tracker');
     // Enable anonymous posting of content.
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(ANONYMOUS_RID, array(
       'create article content' => TRUE,
       'access comments' => TRUE,
       'post comments' => TRUE,
@@ -687,7 +688,7 @@ class RdfTrackerAttributesTestCase extends DrupalWebTestCase {
 /**
  * Tests for RDF namespaces declaration with hook_rdf_namespaces().
  */
-class RdfGetRdfNamespacesTestCase extends DrupalWebTestCase {
+class RdfGetRdfNamespacesTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'RDF namespaces',
@@ -717,7 +718,7 @@ class RdfGetRdfNamespacesTestCase extends DrupalWebTestCase {
 /**
  * Tests for RDF namespaces XML serialization.
  */
-class DrupalGetRdfNamespacesTestCase extends DrupalWebTestCase {
+class GetRdfNamespacesTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'RDF namespaces serialization test',
diff --git a/core/modules/rdf/tests/rdf_test.install b/core/modules/rdf/tests/rdf_test.install
index 91a3392..2375b32 100644
--- a/core/modules/rdf/tests/rdf_test.install
+++ b/core/modules/rdf/tests/rdf_test.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/rdf/tests/rdf_test.module b/core/modules/rdf/tests/rdf_test.module
index 4ad43f3..04d15d5 100644
--- a/core/modules/rdf/tests/rdf_test.module
+++ b/core/modules/rdf/tests/rdf_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/search/search-result.tpl.php b/core/modules/search/search-result.tpl.php
index 949452a..f42ce3c 100644
--- a/core/modules/search/search-result.tpl.php
+++ b/core/modules/search/search-result.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/search/search-results.tpl.php b/core/modules/search/search-results.tpl.php
index e35be1e..d6cc948 100644
--- a/core/modules/search/search-results.tpl.php
+++ b/core/modules/search/search-results.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -29,5 +30,5 @@
   <?php print $pager; ?>
 <?php else : ?>
   <h2><?php print t('Your search yielded no results');?></h2>
-  <?php print search_help('search#noresults', drupal_help_arg()); ?>
+  <?php print search_help('search#noresults', help_arg()); ?>
 <?php endif; ?>
diff --git a/core/modules/search/search.admin.inc b/core/modules/search/search.admin.inc
index fda14ee..e7926f8 100644
--- a/core/modules/search/search.admin.inc
+++ b/core/modules/search/search.admin.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -19,7 +20,7 @@ function search_reindex_confirm() {
 function search_reindex_confirm_submit(&$form, &$form_state) {
   if ($form['confirm']) {
     search_reindex();
-    drupal_set_message(t('The index will be rebuilt.'));
+    set_message(t('The index will be rebuilt.'));
     $form_state['redirect'] = 'admin/config/search/settings';
     return;
   }
@@ -67,7 +68,7 @@ function search_admin_settings($form) {
   $form['status']['status'] = array('#markup' => $status);
   $form['status']['wipe'] = array('#type' => 'submit', '#value' => t('Re-index site'), '#submit' => array('search_admin_reindex_submit'));
 
-  $items = drupal_map_assoc(array(10, 20, 50, 100, 200, 500));
+  $items = map_assoc(array(10, 20, 50, 100, 200, 500));
 
   // Indexing throttle:
   $form['indexing_throttle'] = array(
@@ -159,7 +160,7 @@ function search_admin_settings_submit($form, &$form_state) {
   // If these settings change, the index needs to be rebuilt.
   if ((variable_get('minimum_word_size', 3) != $form_state['values']['minimum_word_size']) ||
       (variable_get('overlap_cjk', TRUE) != $form_state['values']['overlap_cjk'])) {
-    drupal_set_message(t('The index will be rebuilt.'));
+    set_message(t('The index will be rebuilt.'));
     search_reindex();
   }
   $current_modules = variable_get('search_active_modules', array('node', 'user'));
@@ -171,7 +172,7 @@ function search_admin_settings_submit($form, &$form_state) {
     $new_modules = array_filter($form_state['values']['search_active_modules']);
   }
   if (array_diff($current_modules, $new_modules)) {
-    drupal_set_message(t('The active search modules have been changed.'));
+    set_message(t('The active search modules have been changed.'));
     variable_set('menu_rebuild_needed', TRUE);
   }
 }
diff --git a/core/modules/search/search.api.php b/core/modules/search/search.api.php
index 534c1e8..b2f0384 100644
--- a/core/modules/search/search.api.php
+++ b/core/modules/search/search.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -142,7 +143,7 @@ function hook_search_admin() {
   );
 
   // Note: reversed to reflect that higher number = higher ranking.
-  $options = drupal_map_assoc(range(0, 10));
+  $options = map_assoc(range(0, 10));
   foreach (module_invoke_all('ranking') as $var => $values) {
     $form['content_ranking']['factors']['node_rank_' . $var] = array(
       '#title' => $values['title'],
diff --git a/core/modules/search/search.extender.inc b/core/modules/search/search.extender.inc
index ad4b86e..9391612 100644
--- a/core/modules/search/search.extender.inc
+++ b/core/modules/search/search.extender.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -302,7 +303,7 @@ class SearchQuery extends SelectQueryExtender {
     }
 
     if ($warning == 'or') {
-      drupal_set_message(t('Search for either of the two terms with uppercase <strong>OR</strong>. For example, <strong>cats OR dogs</strong>.'));
+      set_message(t('Search for either of the two terms with uppercase <strong>OR</strong>. For example, <strong>cats OR dogs</strong>.'));
     }
   }
 
@@ -346,7 +347,7 @@ class SearchQuery extends SelectQueryExtender {
       return FALSE;
     }
     if ($this->expressionsIgnored) {
-      drupal_set_message(t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', array('@count' => variable_get('search_and_or_limit', 7))), 'warning');
+      set_message(t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', array('@count' => variable_get('search_and_or_limit', 7))), 'warning');
     }
     $this->executedFirstPass = TRUE;
 
diff --git a/core/modules/search/search.install b/core/modules/search/search.install
index c450f05..535226c 100644
--- a/core/modules/search/search.install
+++ b/core/modules/search/search.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/search/search.module b/core/modules/search/search.module
index 14ffc80..cedd243 100644
--- a/core/modules/search/search.module
+++ b/core/modules/search/search.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -137,7 +138,7 @@ function search_permission() {
 function search_block_info() {
   $blocks['form']['info'] = t('Search form');
   // Not worth caching.
-  $blocks['form']['cache'] = DRUPAL_NO_CACHE;
+  $blocks['form']['cache'] = NO_CACHE;
   $blocks['form']['properties']['administrative'] = TRUE;
   return $blocks;
 }
@@ -148,7 +149,7 @@ function search_block_info() {
 function search_block_view($delta = '') {
   if (user_access('search content')) {
     $block['subject'] = t('Search');
-    $block['content'] = drupal_get_form('search_block_form');
+    $block['content'] = get_form('search_block_form');
     return $block;
   }
 }
@@ -177,7 +178,7 @@ function search_menu() {
   $items['admin/config/search/settings'] = array(
     'title' => 'Search settings',
     'description' => 'Configure relevance settings for search and other indexing options.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('search_admin_settings'),
     'access arguments' => array('administer search'),
     'weight' => -10,
@@ -185,7 +186,7 @@ function search_menu() {
   );
   $items['admin/config/search/settings/reindex'] = array(
     'title' => 'Clear index',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('search_reindex_confirm'),
     'access arguments' => array('administer search'),
     'type' => MENU_VISIBLE_IN_BREADCRUMB,
@@ -199,7 +200,7 @@ function search_menu() {
   // system appears to be having two sets of tabs. See discussion on issue
   // http://drupal.org/node/245103 for details.
 
-  drupal_static_reset('search_get_info');
+  drupal_static_reset('Drupal\search_get_info');
   $default_info = search_get_default_module_info();
   if ($default_info) {
     foreach (search_get_info() as $module => $search_info) {
@@ -263,7 +264,7 @@ function search_get_info($all = FALSE) {
 
   if (!isset($search_hooks)) {
     foreach (module_implements('search_info') as $module) {
-      $search_hooks[$module] = call_user_func($module . '_search_info');
+      $search_hooks[$module] = call_user_func('Drupal\\' . $module . '_search_info');
       // Use module name as the default value.
       $search_hooks[$module] += array('title' => $module, 'path' => $module);
       // Include the module name itself in the array.
@@ -300,7 +301,7 @@ function search_get_default_module_info() {
  * Access callback for search tabs.
  */
 function _search_menu_access($name) {
-  return user_access('search content') && (!function_exists($name . '_search_access') || module_invoke($name, 'search_access'));
+  return user_access('search content') && (!function_exists('Drupal\\' . $name . '_search_access') || module_invoke($name, 'search_access'));
 }
 
 /**
@@ -363,7 +364,7 @@ function search_dirty($word = NULL) {
 function search_cron() {
   // We register a shutdown function to ensure that search_total is always up
   // to date.
-  drupal_register_shutdown_function('search_update_totals');
+  drupal_register_shutdown_function('Drupal\search_update_totals');
 
   foreach (variable_get('search_active_modules', array('node', 'user')) as $module) {
     // Update word index
@@ -427,7 +428,7 @@ function search_simplify($text) {
 
   // Simple CJK handling
   if (variable_get('overlap_cjk', TRUE)) {
-    $text = preg_replace_callback('/[' . PREG_CLASS_CJK . ']+/u', 'search_expand_cjk', $text);
+    $text = preg_replace_callback('/[' . PREG_CLASS_CJK . ']+/u', 'Drupal\search_expand_cjk', $text);
   }
 
   // To improve searching for numerical data such as dates, IP addresses
@@ -453,7 +454,7 @@ function search_simplify($text) {
 
   // Truncate everything to 50 characters.
   $words = explode(' ', $text);
-  array_walk($words, '_search_index_truncate');
+  array_walk($words, 'Drupal\_search_index_truncate');
   $text = implode(' ', $words);
 
   return $text;
@@ -638,7 +639,7 @@ function search_index($sid, $module, $text) {
         if ($tagname == 'a') {
           // Check if link points to a node on this site
           if (preg_match($node_regexp, $value, $match)) {
-            $path = drupal_get_normal_path($match[1]);
+            $path = get_normal_path($match[1]);
             if (preg_match('!(?:node|book)/(?:view/)?([0-9]+)!i', $path, $match)) {
               $linknid = $match[1];
               if ($linknid > 0) {
@@ -1033,7 +1034,7 @@ function search_box($form, &$form_state, $form_id) {
 function search_box_form_submit($form, &$form_state) {
   // The search form relies on control of the redirect destination for its
   // functionality, so we override any static destination set in the request,
-  // for example by drupal_access_denied() or drupal_not_found()
+  // for example by access_denied() or not_found()
   // (see http://drupal.org/node/292565).
   if (isset($_GET['destination'])) {
     unset($_GET['destination']);
@@ -1115,7 +1116,7 @@ function search_excerpt($keys, $text) {
   $text = decode_entities($text);
 
   // Slash-escape quotes in the search keyword string.
-  array_walk($keys, '_search_excerpt_replace');
+  array_walk($keys, 'Drupal\_search_excerpt_replace');
   $workkeys = $keys;
 
   // Extract fragments around keywords.
@@ -1227,7 +1228,7 @@ function search_excerpt($keys, $text) {
   $text = check_plain($text);
 
   // Slash-escape quotes in keys found in a derived form and merge with original keys.
-  array_walk($foundkeys, '_search_excerpt_replace');
+  array_walk($foundkeys, 'Drupal\_search_excerpt_replace');
   $keys = array_merge($keys, $foundkeys);
 
   // Highlight keywords. Must be done at once to prevent conflicts ('strong' and '<strong>').
@@ -1279,7 +1280,7 @@ function search_simplify_excerpt_match($key, $text, $offset, $boundary) {
   // If we get here, we have a match. Now find the exact location of the match
   // and the original text that matched. Start by splitting up the text by all
   // potential starting points of the matching text and iterating through them.
-  $split = array_filter(preg_split('/' . $boundary . '/iu', $text, -1, PREG_SPLIT_OFFSET_CAPTURE), '_search_excerpt_match_filter');
+  $split = array_filter(preg_split('/' . $boundary . '/iu', $text, -1, PREG_SPLIT_OFFSET_CAPTURE), 'Drupal\_search_excerpt_match_filter');
   foreach ($split as $value) {
     // Skip starting points before the offset.
     if ($value[1] < $offset) {
diff --git a/core/modules/search/search.pages.inc b/core/modules/search/search.pages.inc
index b5d8722..6933d50 100644
--- a/core/modules/search/search.pages.inc
+++ b/core/modules/search/search.pages.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -40,7 +41,7 @@ function search_view($module = NULL, $keys = '') {
     if ($keys) {
       $path .= '/' . $keys;
     }
-    drupal_goto($path);
+    redirect($path);
   }
 
   // Default results output is an empty string.
@@ -54,7 +55,7 @@ function search_view($module = NULL, $keys = '') {
     $conditions =  NULL;
     if (isset($info['conditions_callback'])) {
       // Build an optional array of more search conditions.
-      $conditions = call_user_func($info['conditions_callback'], $keys);
+      $conditions = call_user_func('Drupal\\' . $info['conditions_callback'], $keys);
     }
     // Only search if there are keywords or non-empty conditions.
     if ($keys || !empty($conditions)) {
@@ -66,7 +67,7 @@ function search_view($module = NULL, $keys = '') {
     }
   }
   // The form may be altered based on whether the search was run.
-  $build['search_form'] = drupal_get_form('search_form', NULL, $keys, $info['module']);
+  $build['search_form'] = get_form('search_form', NULL, $keys, $info['module']);
   $build['search_results'] = $results;
 
   return $build;
diff --git a/core/modules/search/search.test b/core/modules/search/search.test
index 1ee4e6f..2142323 100644
--- a/core/modules/search/search.test
+++ b/core/modules/search/search.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -11,7 +12,7 @@ const SEARCH_TYPE = '_test_';
 const SEARCH_TYPE_2 = '_test2_';
 const SEARCH_TYPE_JPN = '_test3_';
 
-class SearchMatchTestCase extends DrupalWebTestCase {
+class SearchMatchTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Search engine queries',
@@ -243,7 +244,7 @@ class SearchMatchTestCase extends DrupalWebTestCase {
 /**
  * Tests the bike shed text on no results page, and text on the search page.
  */
-class SearchPageText extends DrupalWebTestCase {
+class SearchPageText extends WebTestCase {
   protected $searching_user;
 
   public static function getInfo() {
@@ -307,7 +308,7 @@ class SearchPageText extends DrupalWebTestCase {
   }
 }
 
-class SearchAdvancedSearchForm extends DrupalWebTestCase {
+class SearchAdvancedSearchForm extends WebTestCase {
   protected $node;
 
   public static function getInfo() {
@@ -370,7 +371,7 @@ class SearchAdvancedSearchForm extends DrupalWebTestCase {
   }
 }
 
-class SearchRankingTestCase extends DrupalWebTestCase {
+class SearchRankingTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Search engine ranking',
@@ -580,7 +581,7 @@ class SearchRankingTestCase extends DrupalWebTestCase {
   }
 }
 
-class SearchBlockTestCase extends DrupalWebTestCase {
+class SearchBlockTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Block availability',
@@ -660,7 +661,7 @@ class SearchBlockTestCase extends DrupalWebTestCase {
 /**
  * Tests that searching for a phrase gets the correct page count.
  */
-class SearchExactTestCase extends DrupalWebTestCase {
+class SearchExactTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Search engine phrase queries',
@@ -721,7 +722,7 @@ class SearchExactTestCase extends DrupalWebTestCase {
 /**
  * Test integration searching comments.
  */
-class SearchCommentTestCase extends DrupalWebTestCase {
+class SearchCommentTestCase extends WebTestCase {
   protected $admin_user;
 
   public static function getInfo() {
@@ -756,7 +757,7 @@ class SearchCommentTestCase extends DrupalWebTestCase {
   function testSearchResultsComment() {
     $comment_body = 'Test comment body';
 
-    variable_set('comment_preview_article', DRUPAL_OPTIONAL);
+    variable_set('comment_preview_article', OPTIONAL);
     // Enable check_plain() for 'Filtered HTML' text format.
     $filtered_html_format_id = 'filtered_html';
     $edit = array(
@@ -765,9 +766,9 @@ class SearchCommentTestCase extends DrupalWebTestCase {
     $this->drupalPost('admin/config/content/formats/' . $filtered_html_format_id, $edit, t('Save configuration'));
     // Allow anonymous users to search content.
     $edit = array(
-      DRUPAL_ANONYMOUS_RID . '[search content]' => 1,
-      DRUPAL_ANONYMOUS_RID . '[access comments]' => 1,
-      DRUPAL_ANONYMOUS_RID . '[post comments]' => 1,
+      ANONYMOUS_RID . '[search content]' => 1,
+      ANONYMOUS_RID . '[access comments]' => 1,
+      ANONYMOUS_RID . '[post comments]' => 1,
     );
     $this->drupalPost('admin/people/permissions', $edit, t('Save permissions'));
 
@@ -826,11 +827,11 @@ class SearchCommentTestCase extends DrupalWebTestCase {
     $comment_body = 'Test comment body';
     $this->comment_subject = 'Test comment subject';
     $this->admin_role = $this->admin_user->roles;
-    unset($this->admin_role[DRUPAL_AUTHENTICATED_RID]);
+    unset($this->admin_role[AUTHENTICATED_RID]);
     $this->admin_role = key($this->admin_role);
 
     // Create a node.
-    variable_set('comment_preview_article', DRUPAL_OPTIONAL);
+    variable_set('comment_preview_article', OPTIONAL);
     $this->node = $this->drupalCreateNode(array('type' => 'article'));
 
     // Post a comment using 'Full HTML' text format.
@@ -840,17 +841,17 @@ class SearchCommentTestCase extends DrupalWebTestCase {
     $this->drupalPost('comment/reply/' . $this->node->nid, $edit_comment, t('Save'));
 
     $this->drupalLogout();
-    $this->setRolePermissions(DRUPAL_ANONYMOUS_RID);
+    $this->setRolePermissions(ANONYMOUS_RID);
     $this->checkCommentAccess('Anon user has search permission but no access comments permission, comments should not be indexed');
 
-    $this->setRolePermissions(DRUPAL_ANONYMOUS_RID, TRUE);
+    $this->setRolePermissions(ANONYMOUS_RID, TRUE);
     $this->checkCommentAccess('Anon user has search permission and access comments permission, comments should be indexed', TRUE);
 
     $this->drupalLogin($this->admin_user);
     $this->drupalGet('admin/people/permissions');
 
     // Disable search access for authenticated user to test admin user.
-    $this->setRolePermissions(DRUPAL_AUTHENTICATED_RID, FALSE, FALSE);
+    $this->setRolePermissions(AUTHENTICATED_RID, FALSE, FALSE);
 
     $this->setRolePermissions($this->admin_role);
     $this->checkCommentAccess('Admin user has search permission but no access comments permission, comments should not be indexed');
@@ -858,21 +859,21 @@ class SearchCommentTestCase extends DrupalWebTestCase {
     $this->setRolePermissions($this->admin_role, TRUE);
     $this->checkCommentAccess('Admin user has search permission and access comments permission, comments should be indexed', TRUE);
 
-    $this->setRolePermissions(DRUPAL_AUTHENTICATED_RID);
+    $this->setRolePermissions(AUTHENTICATED_RID);
     $this->checkCommentAccess('Authenticated user has search permission but no access comments permission, comments should not be indexed');
 
-    $this->setRolePermissions(DRUPAL_AUTHENTICATED_RID, TRUE);
+    $this->setRolePermissions(AUTHENTICATED_RID, TRUE);
     $this->checkCommentAccess('Authenticated user has search permission and access comments permission, comments should be indexed', TRUE);
 
     // Verify that access comments permission is inherited from the
     // authenticated role.
-    $this->setRolePermissions(DRUPAL_AUTHENTICATED_RID, TRUE, FALSE);
+    $this->setRolePermissions(AUTHENTICATED_RID, TRUE, FALSE);
     $this->setRolePermissions($this->admin_role);
     $this->checkCommentAccess('Admin user has search permission and no access comments permission, but comments should be indexed because admin user inherits authenticated user\'s permission to access comments', TRUE);
 
     // Verify that search content permission is inherited from the authenticated
     // role.
-    $this->setRolePermissions(DRUPAL_AUTHENTICATED_RID, TRUE, TRUE);
+    $this->setRolePermissions(AUTHENTICATED_RID, TRUE, TRUE);
     $this->setRolePermissions($this->admin_role, TRUE, FALSE);
     $this->checkCommentAccess('Admin user has access comments permission and no search permission, but comments should be indexed because admin user inherits authenticated user\'s permission to search', TRUE);
 
@@ -951,7 +952,7 @@ class SearchCommentTestCase extends DrupalWebTestCase {
  *
  * @see http://drupal.org/node/419388 (issue)
  */
-class SearchExpressionInsertExtractTestCase extends DrupalUnitTestCase {
+class SearchExpressionInsertExtractTestCase extends UnitTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Search expression insert/extract',
@@ -961,7 +962,7 @@ class SearchExpressionInsertExtractTestCase extends DrupalUnitTestCase {
   }
 
   function setUp() {
-    drupal_load('module', 'search');
+    load('module', 'search');
     parent::setUp();
   }
 
@@ -1017,7 +1018,7 @@ class SearchExpressionInsertExtractTestCase extends DrupalUnitTestCase {
  *     only when there are comments
  * - Nodes with comment status set to Hidden should never show comment counts
  */
-class SearchCommentCountToggleTestCase extends DrupalWebTestCase {
+class SearchCommentCountToggleTestCase extends WebTestCase {
   protected $searching_user;
   protected $searchable_nodes;
 
@@ -1102,7 +1103,7 @@ class SearchCommentCountToggleTestCase extends DrupalWebTestCase {
 /**
  * Test search_simplify() on every Unicode character, and some other cases.
  */
-class SearchSimplifyTestCase extends DrupalWebTestCase {
+class SearchSimplifyTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Search simplify',
@@ -1122,7 +1123,7 @@ class SearchSimplifyTestCase extends DrupalWebTestCase {
     // their own lines).  So the even-numbered lines should simplify to nothing,
     // and the odd-numbered lines we need to split into shorter chunks and
     // verify that simplification doesn't lose any characters.
-    $input = file_get_contents(DRUPAL_ROOT . '/core/modules/search/tests/UnicodeTest.txt');
+    $input = file_get_contents(ROOT . '/core/modules/search/tests/UnicodeTest.txt');
     $basestrings = explode(chr(10), $input);
     $strings = array();
     foreach ($basestrings as $key => $string) {
@@ -1185,7 +1186,7 @@ class SearchSimplifyTestCase extends DrupalWebTestCase {
 /**
  * Tests keywords and conditions.
  */
-class SearchKeywordsConditions extends DrupalWebTestCase {
+class SearchKeywordsConditions extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1236,7 +1237,7 @@ class SearchKeywordsConditions extends DrupalWebTestCase {
 /**
  * Tests that numbers can be searched.
  */
-class SearchNumbersTestCase extends DrupalWebTestCase {
+class SearchNumbersTestCase extends WebTestCase {
   protected $test_user;
   protected $numbers;
   protected $nodes;
@@ -1324,7 +1325,7 @@ class SearchNumbersTestCase extends DrupalWebTestCase {
 /**
  * Tests that numbers can be searched, with more complex matching.
  */
-class SearchNumberMatchingTestCase extends DrupalWebTestCase {
+class SearchNumberMatchingTestCase extends WebTestCase {
   protected $test_user;
   protected $numbers;
   protected $nodes;
@@ -1407,7 +1408,7 @@ class SearchNumberMatchingTestCase extends DrupalWebTestCase {
 /**
  * Test config page.
  */
-class SearchConfigSettingsForm extends DrupalWebTestCase {
+class SearchConfigSettingsForm extends WebTestCase {
   public $search_user;
   public $search_node;
 
@@ -1556,7 +1557,7 @@ class SearchConfigSettingsForm extends DrupalWebTestCase {
 /**
  * Tests the search_excerpt() function.
  */
-class SearchExcerptTestCase extends DrupalUnitTestCase {
+class SearchExcerptTestCase extends UnitTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Search excerpt extraction',
@@ -1566,7 +1567,7 @@ class SearchExcerptTestCase extends DrupalUnitTestCase {
   }
 
   function setUp() {
-    drupal_load('module', 'search');
+    load('module', 'search');
     parent::setUp();
   }
 
@@ -1645,7 +1646,7 @@ class SearchExcerptTestCase extends DrupalUnitTestCase {
 /**
  * Test the CJK tokenizer.
  */
-class SearchTokenizerTestCase extends DrupalWebTestCase {
+class SearchTokenizerTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'CJK tokenizer',
@@ -1796,7 +1797,7 @@ class SearchTokenizerTestCase extends DrupalWebTestCase {
 /**
  * Tests that we can embed a form in search results and submit it.
  */
-class SearchEmbedForm extends DrupalWebTestCase {
+class SearchEmbedForm extends WebTestCase {
   /**
    * Node used for testing.
    */
@@ -1872,7 +1873,7 @@ class SearchEmbedForm extends DrupalWebTestCase {
 /**
  * Tests that hook_search_page runs.
  */
-class SearchPageOverride extends DrupalWebTestCase {
+class SearchPageOverride extends WebTestCase {
   public $search_user;
 
   public static function getInfo() {
@@ -1906,7 +1907,7 @@ class SearchPageOverride extends DrupalWebTestCase {
 /**
  * Test node search with multiple languages.
  */
-class SearchLanguageTestCase extends DrupalWebTestCase {
+class SearchLanguageTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Search language selection',
@@ -1971,7 +1972,7 @@ class SearchLanguageTestCase extends DrupalWebTestCase {
 /**
  * Tests node search with node access control.
  */
-class SearchNodeAccessTest extends DrupalWebTestCase {
+class SearchNodeAccessTest extends WebTestCase {
   public $test_user;
 
   public static function getInfo() {
diff --git a/core/modules/search/tests/search_embedded_form.module b/core/modules/search/tests/search_embedded_form.module
index 4845796..03fd62e 100644
--- a/core/modules/search/tests/search_embedded_form.module
+++ b/core/modules/search/tests/search_embedded_form.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -15,7 +16,7 @@
 function search_embedded_form_menu() {
   $items['search_embedded_form'] = array(
     'title' => 'Search_Embed_Form',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('search_embedded_form_form'),
     'access arguments' => array('search content'),
     'type' => MENU_CALLBACK,
@@ -58,13 +59,13 @@ function search_embedded_form_form($form, &$form_state) {
 function search_embedded_form_form_submit($form, &$form_state) {
   $count = variable_get('search_embedded_form_submitted', 0) + 1;
   variable_set('search_embedded_form_submitted', $count);
-  drupal_set_message(t('Test form was submitted'));
+  set_message(t('Test form was submitted'));
 }
 
 /**
  * Adds the test form to search results.
  */
 function search_embedded_form_preprocess_search_result(&$variables) {
-  $form = drupal_get_form('search_embedded_form_form');
+  $form = get_form('search_embedded_form_form');
   $variables['snippet'] .= drupal_render($form);
 }
diff --git a/core/modules/search/tests/search_extra_type.module b/core/modules/search/tests/search_extra_type.module
index 80c050c..820ec0e 100644
--- a/core/modules/search/tests/search_extra_type.module
+++ b/core/modules/search/tests/search_extra_type.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/shortcut/shortcut.admin.inc b/core/modules/shortcut/shortcut.admin.inc
index 75c12b4..2b016c2 100644
--- a/core/modules/shortcut/shortcut.admin.inc
+++ b/core/modules/shortcut/shortcut.admin.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -83,8 +84,8 @@ function shortcut_set_switch($form, &$form_state, $account = NULL) {
     }
 
     $form['#attached'] = array(
-      'css' => array(drupal_get_path('module', 'shortcut') . '/shortcut.admin.css'),
-      'js' => array(drupal_get_path('module', 'shortcut') . '/shortcut.admin.js'),
+      'css' => array(get_path('module', 'shortcut') . '/shortcut.admin.css'),
+      'js' => array(get_path('module', 'shortcut') . '/shortcut.admin.js'),
     );
 
     $form['actions'] = array('#type' => 'actions');
@@ -142,10 +143,10 @@ function shortcut_set_switch_submit($form, &$form_state) {
     if ($account->uid == $user->uid) {
       // Only administrators can create new shortcut sets, so we know they have
       // access to switch back.
-      drupal_set_message(t('You are now using the new %set_name shortcut set. You can edit it from this page or <a href="@switch-url">switch back to a different one.</a>', $replacements));
+      set_message(t('You are now using the new %set_name shortcut set. You can edit it from this page or <a href="@switch-url">switch back to a different one.</a>', $replacements));
     }
     else {
-      drupal_set_message(t('%user is now using a new shortcut set called %set_name. You can edit it from this page.', $replacements));
+      set_message(t('%user is now using a new shortcut set called %set_name. You can edit it from this page.', $replacements));
     }
     $form_state['redirect'] = 'admin/config/user-interface/shortcut/' . $set->set_name;
   }
@@ -156,7 +157,7 @@ function shortcut_set_switch_submit($form, &$form_state) {
       '%user' => $account->name,
       '%set_name' => $set->title,
     );
-    drupal_set_message($account->uid == $user->uid ? t('You are now using the %set_name shortcut set.', $replacements) : t('%user is now using the %set_name shortcut set.', $replacements));
+    set_message($account->uid == $user->uid ? t('You are now using the %set_name shortcut set.', $replacements) : t('%user is now using the %set_name shortcut set.', $replacements));
   }
 
   // Assign the shortcut set to the provided user account.
@@ -243,7 +244,7 @@ function shortcut_set_add_form_submit($form, &$form_state) {
     'links' => menu_links_clone($default_set->links),
   );
   shortcut_set_save($set);
-  drupal_set_message(t('The %set_name shortcut set has been created. You can edit it from this page.', array('%set_name' => $set->title)));
+  set_message(t('The %set_name shortcut set has been created. You can edit it from this page.', array('%set_name' => $set->title)));
   $form_state['redirect'] = 'admin/config/user-interface/shortcut/' . $set->set_name;
 }
 
@@ -296,8 +297,8 @@ function shortcut_set_customize($form, &$form_state, $shortcut_set) {
   }
 
   $form['#attached'] = array(
-    'css' => array(drupal_get_path('module', 'shortcut') . '/shortcut.admin.css'),
-    'js' => array(drupal_get_path('module', 'shortcut') . '/shortcut.admin.js'),
+    'css' => array(get_path('module', 'shortcut') . '/shortcut.admin.css'),
+    'js' => array(get_path('module', 'shortcut') . '/shortcut.admin.js'),
   );
 
   $form['actions'] = array(
@@ -324,7 +325,7 @@ function shortcut_set_customize_submit($form, &$form_state) {
       menu_link_save($link);
     }
   }
-  drupal_set_message(t('The shortcut set has been updated.'));
+  set_message(t('The shortcut set has been updated.'));
 }
 
 /**
@@ -349,8 +350,8 @@ function theme_shortcut_set_customize($variables) {
 
   $rows = array();
   foreach ($statuses as $status) {
-    drupal_add_tabledrag('shortcuts', 'match', 'sibling', 'shortcut-status-select');
-    drupal_add_tabledrag('shortcuts', 'order', 'sibling', 'shortcut-weight');
+    add_tabledrag('shortcuts', 'match', 'sibling', 'shortcut-status-select');
+    add_tabledrag('shortcuts', 'order', 'sibling', 'shortcut-weight');
     $rows[] = array(
       'data' => array(array(
         'colspan' => 5,
@@ -395,7 +396,7 @@ function theme_shortcut_set_customize($variables) {
   $header = array(t('Name'), t('Weight'), t('Status'), array('data' => t('Operations'), 'colspan' => 2));
   $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'shortcuts'), 'empty' => t('No shortcuts available. <a href="@link">Add a shortcut</a>.', array('@link' => url('admin/config/user-interface/shortcut/' . $form['#shortcut_set_name'] . '/add-link')))));
   $output .= drupal_render($form['actions']);
-  $output = drupal_render_children($form) . $output;
+  $output = render_children($form) . $output;
   return $output;
 }
 
@@ -417,7 +418,7 @@ function theme_shortcut_set_customize($variables) {
  * @see shortcut_link_add_submit()
  */
 function shortcut_link_add($form, &$form_state, $shortcut_set) {
-  drupal_set_title(t('Add new shortcut'));
+  set_title(t('Add new shortcut'));
   $form['shortcut_set'] = array(
     '#type' => 'value',
     '#value' => $shortcut_set,
@@ -444,7 +445,7 @@ function shortcut_link_add($form, &$form_state, $shortcut_set) {
  * @see shortcut_link_edit_submit()
  */
 function shortcut_link_edit($form, &$form_state, $shortcut_link) {
-  drupal_set_title(t('Editing @shortcut', array('@shortcut' => $shortcut_link['link_title'])));
+  set_title(t('Editing @shortcut', array('@shortcut' => $shortcut_link['link_title'])));
   $form['original_shortcut_link'] = array(
     '#type' => 'value',
     '#value' => $shortcut_link,
@@ -471,7 +472,7 @@ function _shortcut_link_form_elements($shortcut_link = NULL) {
     );
   }
   else {
-    $shortcut_link['link_path'] = drupal_get_path_alias($shortcut_link['link_path']);
+    $shortcut_link['link_path'] = get_path_alias($shortcut_link['link_path']);
   }
 
   $form['shortcut_link']['#tree'] = TRUE;
@@ -518,13 +519,13 @@ function shortcut_link_edit_validate($form, &$form_state) {
  */
 function shortcut_link_edit_submit($form, &$form_state) {
   // Normalize the path in case it is an alias.
-  $form_state['values']['shortcut_link']['link_path'] = drupal_get_normal_path($form_state['values']['shortcut_link']['link_path']);
+  $form_state['values']['shortcut_link']['link_path'] = get_normal_path($form_state['values']['shortcut_link']['link_path']);
 
   $shortcut_link = array_merge($form_state['values']['original_shortcut_link'], $form_state['values']['shortcut_link']);
 
   menu_link_save($shortcut_link);
   $form_state['redirect'] = 'admin/config/user-interface/shortcut/' . $shortcut_link['menu_name'];
-  drupal_set_message(t('The shortcut %link has been updated.', array('%link' => $shortcut_link['link_title'])));
+  set_message(t('The shortcut %link has been updated.', array('%link' => $shortcut_link['link_title'])));
 }
 
 /**
@@ -538,7 +539,7 @@ function shortcut_link_add_submit($form, &$form_state) {
   shortcut_admin_add_link($shortcut_link, $shortcut_set, shortcut_max_slots());
   shortcut_set_save($shortcut_set);
   $form_state['redirect'] = 'admin/config/user-interface/shortcut/' . $shortcut_link['menu_name'];
-  drupal_set_message(t('Added a shortcut for %title.', array('%title' => $shortcut_link['link_title'])));
+  set_message(t('Added a shortcut for %title.', array('%title' => $shortcut_link['link_title'])));
 }
 
 /**
@@ -574,7 +575,7 @@ function shortcut_admin_add_link($shortcut_link, &$shortcut_set, $limit = NULL)
   }
 
   // Normalize the path in case it is an alias.
-  $shortcut_link['link_path'] = drupal_get_normal_path($shortcut_link['link_path']);
+  $shortcut_link['link_path'] = get_normal_path($shortcut_link['link_path']);
 
   // Add the link to the end of the list.
   $shortcut_set->links[] = $shortcut_link;
@@ -640,7 +641,7 @@ function shortcut_set_edit_form_submit($form, &$form_state) {
   $shortcut_set = $form_state['values']['shortcut_set'];
   $shortcut_set->title = $form_state['values']['title'];
   shortcut_set_save($shortcut_set);
-  drupal_set_message(t('Updated set name to %set-name.', array('%set-name' => $shortcut_set->title)));
+  set_message(t('Updated set name to %set-name.', array('%set-name' => $shortcut_set->title)));
   $form_state['redirect'] = "admin/config/user-interface/shortcut/$shortcut_set->set_name";
 }
 
@@ -704,7 +705,7 @@ function shortcut_set_delete_form_submit($form, &$form_state) {
   $shortcut_set = shortcut_set_load($form_state['values']['shortcut_set']);
   shortcut_set_delete($shortcut_set);
   $form_state['redirect'] = 'admin/config/user-interface/shortcut';
-  drupal_set_message(t('The shortcut set %title has been deleted.', array('%title' => $shortcut_set->title)));
+  set_message(t('The shortcut set %title has been deleted.', array('%title' => $shortcut_set->title)));
 }
 
 /**
@@ -746,7 +747,7 @@ function shortcut_link_delete_submit($form, &$form_state) {
   $shortcut_link = $form_state['values']['shortcut_link'];
   menu_link_delete($shortcut_link['mlid']);
   $form_state['redirect'] = 'admin/config/user-interface/shortcut/' . $shortcut_link['menu_name'];
-  drupal_set_message(t('The shortcut %title has been deleted.', array('%title' => $shortcut_link['link_title'])));
+  set_message(t('The shortcut %title has been deleted.', array('%title' => $shortcut_link['link_title'])));
 }
 
 /**
@@ -758,7 +759,7 @@ function shortcut_link_delete_submit($form, &$form_state) {
  *   Returned from shortcut_set_load().
  */
 function shortcut_link_add_inline($shortcut_set) {
-  if (isset($_REQUEST['token']) && drupal_valid_token($_REQUEST['token'], 'shortcut-add-link') && shortcut_valid_link($_GET['link'])) {
+  if (isset($_REQUEST['token']) && valid_token($_REQUEST['token'], 'shortcut-add-link') && shortcut_valid_link($_GET['link'])) {
     $item = menu_get_item($_GET['link']);
     $title = ($item && $item['title']) ? $item['title'] : $_GET['name'];
     $link = array(
@@ -767,13 +768,13 @@ function shortcut_link_add_inline($shortcut_set) {
     );
     shortcut_admin_add_link($link, $shortcut_set, shortcut_max_slots());
     if (shortcut_set_save($shortcut_set)) {
-      drupal_set_message(t('Added a shortcut for %title.', array('%title' => $link['link_title'])));
+      set_message(t('Added a shortcut for %title.', array('%title' => $link['link_title'])));
     }
     else {
-      drupal_set_message(t('Unable to add a shortcut for %title.', array('%title' => $link['link_title'])));
+      set_message(t('Unable to add a shortcut for %title.', array('%title' => $link['link_title'])));
     }
-    drupal_goto();
+    redirect();
   }
 
-  return drupal_access_denied();
+  return access_denied();
 }
diff --git a/core/modules/shortcut/shortcut.api.php b/core/modules/shortcut/shortcut.api.php
index 717a7c9..d8f2ef0 100644
--- a/core/modules/shortcut/shortcut.api.php
+++ b/core/modules/shortcut/shortcut.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/shortcut/shortcut.install b/core/modules/shortcut/shortcut.install
index 7aee9c9..3a99f58 100644
--- a/core/modules/shortcut/shortcut.install
+++ b/core/modules/shortcut/shortcut.install
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -30,7 +32,7 @@ function shortcut_install() {
   // set, to make sure the links defined above can be correctly saved. (During
   // installation, the menu might not have been built at all yet, or it might
   // have been built but without the node module's links in it.)
-  if (drupal_installation_attempted()) {
+  if (installation_attempted()) {
     menu_rebuild();
   }
   shortcut_set_save($shortcut_set);
@@ -40,7 +42,7 @@ function shortcut_install() {
  * Implements hook_uninstall().
  */
 function shortcut_uninstall() {
-  drupal_load('module', 'shortcut');
+  load('module', 'shortcut');
   // Delete the menu links associated with each shortcut set.
   foreach (shortcut_sets() as $shortcut_set) {
     menu_delete_links($shortcut_set->set_name);
diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module
index b057e4b..8897428 100644
--- a/core/modules/shortcut/shortcut.module
+++ b/core/modules/shortcut/shortcut.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -76,7 +77,7 @@ function shortcut_menu() {
   );
   $items['admin/config/user-interface/shortcut/add-set'] = array(
     'title' => 'Add shortcut set',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('shortcut_set_add_form'),
     'access arguments' => array('administer shortcuts'),
     'type' => MENU_LOCAL_ACTION,
@@ -84,7 +85,7 @@ function shortcut_menu() {
   );
   $items['admin/config/user-interface/shortcut/%shortcut_set'] = array(
     'title' => 'Edit shortcuts',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('shortcut_set_customize', 4),
     'title callback' => 'shortcut_set_title',
     'title arguments' => array(4),
@@ -98,7 +99,7 @@ function shortcut_menu() {
   );
   $items['admin/config/user-interface/shortcut/%shortcut_set/edit'] = array(
     'title' => 'Edit set name',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('shortcut_set_edit_form', 4),
     'access callback' => 'shortcut_set_edit_access',
     'access arguments' => array(4),
@@ -108,7 +109,7 @@ function shortcut_menu() {
   );
   $items['admin/config/user-interface/shortcut/%shortcut_set/delete'] = array(
     'title' => 'Delete shortcut set',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('shortcut_set_delete_form', 4),
     'access callback' => 'shortcut_set_delete_access',
     'access arguments' => array(4),
@@ -116,7 +117,7 @@ function shortcut_menu() {
   );
   $items['admin/config/user-interface/shortcut/%shortcut_set/add-link'] = array(
     'title' => 'Add shortcut',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('shortcut_link_add', 4),
     'access callback' => 'shortcut_set_edit_access',
     'access arguments' => array(4),
@@ -134,7 +135,7 @@ function shortcut_menu() {
   );
   $items['admin/config/user-interface/shortcut/link/%menu_link'] = array(
     'title' => 'Edit shortcut',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('shortcut_link_edit', 5),
     'access callback' => 'shortcut_link_access',
     'access arguments' => array(5),
@@ -142,7 +143,7 @@ function shortcut_menu() {
   );
   $items['admin/config/user-interface/shortcut/link/%menu_link/delete'] = array(
     'title' => 'Delete shortcut',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('shortcut_link_delete', 5),
     'access callback' => 'shortcut_link_access',
     'access arguments' => array(5),
@@ -150,7 +151,7 @@ function shortcut_menu() {
   );
   $items['user/%user/shortcuts'] = array(
     'title' => 'Shortcuts',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('shortcut_set_switch', 1),
     'access callback' => 'shortcut_set_switch_access',
     'access arguments' => array(1),
@@ -190,7 +191,7 @@ function shortcut_block_info() {
   $blocks['shortcuts']['info'] = t('Shortcuts');
   // Shortcut blocks can't be cached because each menu item can have a custom
   // access callback. menu.inc manages its own caching.
-  $blocks['shortcuts']['cache'] = DRUPAL_NO_CACHE;
+  $blocks['shortcuts']['cache'] = NO_CACHE;
   return $blocks;
 }
 
@@ -351,11 +352,11 @@ function shortcut_set_load($set_name) {
 function shortcut_set_save(&$shortcut_set) {
   // First save the shortcut set itself.
   if (isset($shortcut_set->set_name)) {
-    $return = drupal_write_record('shortcut_set', $shortcut_set, 'set_name');
+    $return = write_record('shortcut_set', $shortcut_set, 'set_name');
   }
   else {
     $shortcut_set->set_name = shortcut_set_get_unique_name();
-    $return = drupal_write_record('shortcut_set', $shortcut_set);
+    $return = write_record('shortcut_set', $shortcut_set);
   }
   // If links were provided for the set, save them.
   if (isset($shortcut_set->links)) {
@@ -368,7 +369,7 @@ function shortcut_set_save(&$shortcut_set) {
       menu_link_save($link);
     }
     // Make sure that we have a return value, since if the links were updated
-    // but the shortcut set was not, the call to drupal_write_record() above
+    // but the shortcut set was not, the call to write_record() above
     // would not return an indication that anything had changed.
     if (empty($return)) {
       $return = SAVED_UPDATED;
@@ -443,7 +444,7 @@ function shortcut_set_assign_user($shortcut_set, $account) {
     ->key(array('uid' => $account->uid))
     ->fields(array('set_name' => $shortcut_set->set_name))
     ->execute();
-  drupal_static_reset('shortcut_current_displayed_set');
+  drupal_static_reset('Drupal\shortcut_current_displayed_set');
 }
 
 /**
@@ -613,7 +614,7 @@ function shortcut_set_title_exists($title) {
  */
 function shortcut_valid_link($path) {
   // Do not use URL aliases.
-  $normal_path = drupal_get_normal_path($path);
+  $normal_path = get_normal_path($path);
   if ($path != $normal_path) {
     $path = $normal_path;
   }
@@ -658,15 +659,15 @@ function shortcut_preprocess_page(&$variables) {
   // pages).
   if (shortcut_set_edit_access() && ($item = menu_get_item()) && $item['access']) {
     $link = $_GET['q'];
-    $query_parameters = drupal_get_query_parameters();
+    $query_parameters = get_query_parameters();
     if (!empty($query_parameters)) {
      $link .= '?' . drupal_http_build_query($query_parameters);
     }
     $query = array(
      'link' => $link,
-     'name' => drupal_get_title(),
+     'name' => get_title(),
     );
-    $query += drupal_get_destination();
+    $query += get_destination();
 
     $shortcut_set = shortcut_current_displayed_set();
 
@@ -680,7 +681,7 @@ function shortcut_preprocess_page(&$variables) {
     $link_mode = isset($mlid) ? "remove" : "add";
 
     if ($link_mode == "add") {
-      $query['token'] = drupal_get_token('shortcut-add-link');
+      $query['token'] = get_token('shortcut-add-link');
       $link_text = shortcut_set_switch_access() ? t('Add to %shortcut_set shortcuts', array('%shortcut_set' => $shortcut_set->title)) : t('Add to shortcuts');
       $link_path = 'admin/config/user-interface/shortcut/' . $shortcut_set->set_name . '/add-link-inline';
     }
@@ -692,7 +693,7 @@ function shortcut_preprocess_page(&$variables) {
 
     if (theme_get_setting('shortcut_module_link')) {
       $variables['title_suffix']['add_or_remove_shortcut'] = array(
-        '#attached' => array('css' => array(drupal_get_path('module', 'shortcut') . '/shortcut.css')),
+        '#attached' => array('css' => array(get_path('module', 'shortcut') . '/shortcut.css')),
         '#prefix' => '<div class="add-or-remove-shortcuts ' . $link_mode . '-shortcut">',
         '#type' => 'link',
         '#title' => '<span class="icon"></span><span class="text">' . $link_text . '</span>',
@@ -720,7 +721,7 @@ function shortcut_page_alter(&$page) {
  */
 function shortcut_toolbar_pre_render($toolbar) {
   $links = shortcut_renderable_links();
-  $links['#attached'] = array('css' => array(drupal_get_path('module', 'shortcut') . '/shortcut.css'));
+  $links['#attached'] = array('css' => array(get_path('module', 'shortcut') . '/shortcut.css'));
   $links['#prefix'] = '<div class="toolbar-shortcuts">';
   $links['#suffix'] = '</div>';
   $shortcut_set = shortcut_current_displayed_set();
diff --git a/core/modules/shortcut/shortcut.test b/core/modules/shortcut/shortcut.test
index 322c63f..4136041 100644
--- a/core/modules/shortcut/shortcut.test
+++ b/core/modules/shortcut/shortcut.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -8,7 +10,7 @@
 /**
  * Defines base class for shortcut test cases.
  */
-class ShortcutTestCase extends DrupalWebTestCase {
+class ShortcutTestCase extends WebTestCase {
 
   /**
    * User with permission to administer shortcuts.
@@ -141,7 +143,7 @@ class ShortcutLinksTestCase extends ShortcutTestCase {
       $this->assertResponse(200);
       $saved_set = shortcut_set_load($set->set_name);
       $paths = $this->getShortcutInformation($saved_set, 'link_path');
-      $this->assertTrue(in_array(drupal_get_normal_path($test['path']), $paths), 'Shortcut created: '. $test['path']);
+      $this->assertTrue(in_array(get_normal_path($test['path']), $paths), 'Shortcut created: '. $test['path']);
       $this->assertLink($title, 0, 'Shortcut link found on the page.');
     }
   }
diff --git a/core/modules/simpletest/drupal_web_test_case.php b/core/modules/simpletest/drupal_web_test_case.php
index 6adaf93..70ef675 100644
--- a/core/modules/simpletest/drupal_web_test_case.php
+++ b/core/modules/simpletest/drupal_web_test_case.php
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use DOMDocument, DOMXPath, Exception, PDO, ReflectionMethod, ReflectionObject, SimpleXMLElement, stdClass;
 
 /**
  * Global variable that holds information about the tests being run.
@@ -10,14 +12,14 @@
  *
  * @var array
  */
-global $drupal_test_info;
+global $test_info;
 
 /**
  * Base class for Drupal tests.
  *
  * Do not extend this class, use one of the subclasses in this file.
  */
-abstract class DrupalTestCase {
+abstract class TestCase {
   /**
    * The test run ID.
    *
@@ -86,7 +88,7 @@ abstract class DrupalTestCase {
   protected $setup = FALSE;
 
   /**
-   * Constructor for DrupalTestCase.
+   * Constructor for TestCase.
    *
    * @param $test_id
    *   Tests with the same id are reported together.
@@ -96,7 +98,7 @@ abstract class DrupalTestCase {
   }
 
   /**
-   * Checks the matching requirements for DrupalTestCase.
+   * Checks the matching requirements for TestCase.
    *
    * @return
    *   Array of errors containing a list of unmet requirements.
@@ -179,14 +181,14 @@ abstract class DrupalTestCase {
    * the test case has been destroyed, such as PHP fatal errors. The caller
    * information is not automatically gathered since the caller is most likely
    * inserting the assertion on behalf of other code. In all other respects
-   * the method behaves just like DrupalTestCase::assert() in terms of storing
+   * the method behaves just like TestCase::assert() in terms of storing
    * the assertion.
    *
    * @return
    *   Message ID of the stored assertion.
    *
-   * @see DrupalTestCase::assert()
-   * @see DrupalTestCase::deleteAssert()
+   * @see TestCase::assert()
+   * @see TestCase::deleteAssert()
    */
   public static function insertAssert($test_id, $test_class, $status, $message = '', $group = 'Other', array $caller = array()) {
     // Convert boolean status to string status.
@@ -224,7 +226,7 @@ abstract class DrupalTestCase {
    * @return
    *   TRUE if the assertion was deleted, FALSE otherwise.
    *
-   * @see DrupalTestCase::insertAssert()
+   * @see TestCase::insertAssert()
    */
   public static function deleteAssert($message_id) {
     return (bool) db_delete('simpletest')
@@ -251,7 +253,7 @@ abstract class DrupalTestCase {
       array_shift($backtrace);
     }
 
-    return _drupal_get_last_caller($backtrace);
+    return _get_last_caller($backtrace);
   }
 
   /**
@@ -453,7 +455,7 @@ abstract class DrupalTestCase {
    */
   protected function verbose($message) {
     if ($id = simpletest_verbose($message)) {
-      $url = file_create_url($this->originalFileDirectory . '/simpletest/verbose/' . get_class($this) . '-' . $id . '.html');
+      $url = file_create_url($this->originalFileDirectory . '/simpletest/verbose/' . str_replace('\\', '-', get_class($this)) . '-' . $id . '.html');
       $this->error(l(t('Verbose message'), $url, array('attributes' => array('target' => '_blank'))), 'User notice');
     }
   }
@@ -498,7 +500,7 @@ abstract class DrupalTestCase {
         'file' => $missing_requirements_object->getFileName(),
       );
       foreach ($missing_requirements as $missing_requirement) {
-        DrupalTestCase::insertAssert($this->testId, $class, FALSE, $missing_requirement, 'Requirements check.', $caller);
+        TestCase::insertAssert($this->testId, $class, FALSE, $missing_requirement, 'Requirements check.', $caller);
       }
     }
     else {
@@ -513,7 +515,7 @@ abstract class DrupalTestCase {
             'line' => $method_info->getStartLine(),
             'function' => $class . '->' . $method . '()',
           );
-          $completion_check_id = DrupalTestCase::insertAssert($this->testId, $class, FALSE, t('The test did not complete due to a fatal error.'), 'Completion check', $caller);
+          $completion_check_id = TestCase::insertAssert($this->testId, $class, FALSE, t('The test did not complete due to a fatal error.'), 'Completion check', $caller);
           $this->setUp();
           if ($this->setup) {
             try {
@@ -529,12 +531,12 @@ abstract class DrupalTestCase {
             $this->fail(t("The test cannot be executed because it has not been set up properly."));
           }
           // Remove the completion check record.
-          DrupalTestCase::deleteAssert($completion_check_id);
+          TestCase::deleteAssert($completion_check_id);
         }
       }
     }
     // Clear out the error messages and restore error handler.
-    drupal_get_messages();
+    get_messages();
     restore_error_handler();
   }
 
@@ -559,7 +561,7 @@ abstract class DrupalTestCase {
       );
 
       $backtrace = debug_backtrace();
-      $this->error($message, $error_map[$severity], _drupal_get_last_caller($backtrace));
+      $this->error($message, $error_map[$severity], _get_last_caller($backtrace));
     }
     return TRUE;
   }
@@ -576,9 +578,9 @@ abstract class DrupalTestCase {
       'line' => $exception->getLine(),
       'file' => $exception->getFile(),
     ));
-    require_once DRUPAL_ROOT . '/core/includes/errors.inc';
-    // The exception message is run through check_plain() by _drupal_decode_exception().
-    $this->error(t('%type: !message in %function (line %line of %file).', _drupal_decode_exception($exception)), 'Uncaught exception', _drupal_get_last_caller($backtrace));
+    require_once ROOT . '/core/includes/errors.inc';
+    // The exception message is run through check_plain() by _decode_exception().
+    $this->error(t('%type: !message in %function (line %line of %file).', _decode_exception($exception)), 'Uncaught exception', _get_last_caller($backtrace));
   }
 
   /**
@@ -682,10 +684,10 @@ abstract class DrupalTestCase {
  * function that needs the database will throw exceptions. These include
  * watchdog(), module_implements(), module_invoke_all() etc.
  */
-class DrupalUnitTestCase extends DrupalTestCase {
+class UnitTestCase extends TestCase {
 
   /**
-   * Constructor for DrupalUnitTestCase.
+   * Constructor for UnitTestCase.
    */
   function __construct($test_id = NULL) {
     parent::__construct($test_id);
@@ -695,7 +697,7 @@ class DrupalUnitTestCase extends DrupalTestCase {
   /**
    * Sets up unit test environment.
    *
-   * Unlike DrupalWebTestCase::setUp(), DrupalUnitTestCase::setUp() does not
+   * Unlike WebTestCase::setUp(), UnitTestCase::setUp() does not
    * install modules because tests are performed without accessing the database.
    * Any required files must be explicitly included by the child class setUp()
    * method.
@@ -759,7 +761,7 @@ class DrupalUnitTestCase extends DrupalTestCase {
 /**
  * Test case for typical Drupal tests.
  */
-class DrupalWebTestCase extends DrupalTestCase {
+class WebTestCase extends TestCase {
   /**
    * The profile to install as a basis for testing.
    *
@@ -834,7 +836,7 @@ class DrupalWebTestCase extends DrupalTestCase {
   /**
    * Additional cURL options.
    *
-   * DrupalWebTestCase itself never sets this but always obeys what is set.
+   * WebTestCase itself never sets this but always obeys what is set.
    */
   protected $additionalCurlOptions = array();
 
@@ -883,7 +885,7 @@ class DrupalWebTestCase extends DrupalTestCase {
   protected $redirect_count;
 
   /**
-   * Constructor for DrupalWebTestCase.
+   * Constructor for WebTestCase.
    */
   function __construct($test_id = NULL) {
     parent::__construct($test_id);
@@ -1049,7 +1051,7 @@ class DrupalWebTestCase extends DrupalTestCase {
       }
 
       // Copy other test files from simpletest.
-      $original = drupal_get_path('module', 'simpletest') . '/files';
+      $original = get_path('module', 'simpletest') . '/files';
       $files = file_scan_directory($original, '/(html|image|javascript|php|sql)-.*/');
       foreach ($files as $file) {
         file_unmanaged_copy($file->uri, variable_get('file_public_path', conf_path() . '/files'));
@@ -1123,7 +1125,7 @@ class DrupalWebTestCase extends DrupalTestCase {
       $edit['roles'] = array($rid => $rid);
     }
 
-    $account = user_save(drupal_anonymous_user(), $edit);
+    $account = user_save(anonymous_user(), $edit);
 
     $this->assertTrue(!empty($account->uid), t('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass'])), t('User login'));
     if (empty($account->uid)) {
@@ -1251,8 +1253,8 @@ class DrupalWebTestCase extends DrupalTestCase {
    * Generate a token for the currently logged in user.
    */
   protected function drupalGetToken($value = '') {
-    $private_key = drupal_get_private_key();
-    return drupal_hmac_base64($value, $this->session_id . $private_key);
+    $private_key = get_private_key();
+    return hmac_base64($value, $this->session_id . $private_key);
   }
 
   /*
@@ -1311,7 +1313,7 @@ class DrupalWebTestCase extends DrupalTestCase {
     $this->originalLanguage = $language;
     $this->originalLanguageDefault = variable_get('language_default');
     $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files');
-    $this->originalProfile = drupal_get_profile();
+    $this->originalProfile = get_profile();
     $clean_url_original = variable_get('clean_url', 0);
 
     // Set to English to prevent exceptions from utf8_truncate() from t()
@@ -1351,19 +1353,19 @@ class DrupalWebTestCase extends DrupalTestCase {
     ini_set('error_log', $public_files_directory . '/error.log');
 
     // Set the test information for use in other parts of Drupal.
-    $test_info = &$GLOBALS['drupal_test_info'];
+    $test_info = &$GLOBALS['test_info'];
     $test_info['test_run_id'] = $this->databasePrefix;
     $test_info['in_child_site'] = FALSE;
 
     // Preset the 'install_profile' system variable, so the first call into
-    // system_rebuild_module_data() (in drupal_install_system()) will register
+    // system_rebuild_module_data() (in install_system()) will register
     // the test's profile as a module. Without this, the installation profile of
     // the parent site (executing the test) is registered, and the test
     // profile's hook_install() and other hook implementations are never invoked.
     $conf['install_profile'] = $this->profile;
 
-    include_once DRUPAL_ROOT . '/core/includes/install.inc';
-    drupal_install_system();
+    include_once ROOT . '/core/includes/install.inc';
+    install_system();
 
     $this->preloadRegistry();
 
@@ -1405,11 +1407,11 @@ class DrupalWebTestCase extends DrupalTestCase {
 
     // Run cron once in that environment, as install.php does at the end of
     // the installation process.
-    drupal_cron_run();
+    cron_run();
 
     // Log in with a clean $user.
     $this->originalUser = $user;
-    drupal_save_session(FALSE);
+    save_session(FALSE);
     $user = user_load(1);
 
     // Restore necessary variables.
@@ -1431,7 +1433,7 @@ class DrupalWebTestCase extends DrupalTestCase {
   /**
    * Preload the registry from the testing site.
    *
-   * This method is called by DrupalWebTestCase::setUp(), and preloads the
+   * This method is called by WebTestCase::setUp(), and preloads the
    * registry from the testing site to cut down on the time it takes to
    * set up a clean environment for the current test run.
    */
@@ -1467,7 +1469,7 @@ class DrupalWebTestCase extends DrupalTestCase {
   /**
    * Reset all data structures after having enabled new modules.
    *
-   * This method is called by DrupalWebTestCase::setUp() after enabling
+   * This method is called by WebTestCase::setUp() after enabling
    * the requested modules. It must be called again when additional modules
    * are enabled later.
    */
@@ -1478,12 +1480,12 @@ class DrupalWebTestCase extends DrupalTestCase {
     module_list(TRUE);
 
     // Reset cached schema for new database prefix. This must be done before
-    // drupal_flush_all_caches() so rebuilds can make use of the schema of
+    // flush_all_caches() so rebuilds can make use of the schema of
     // modules enabled on the cURL side.
-    drupal_get_schema(NULL, TRUE);
+    get_schema(NULL, TRUE);
 
     // Perform rebuilds and flush remaining caches.
-    drupal_flush_all_caches();
+    flush_all_caches();
 
     // Reload global $conf array and permissions.
     $this->refreshVariables();
@@ -1529,7 +1531,7 @@ class DrupalWebTestCase extends DrupalTestCase {
     file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10));
 
     // Remove all prefixed tables (all the tables in the schema).
-    $schema = drupal_get_schema(NULL, TRUE);
+    $schema = get_schema(NULL, TRUE);
     foreach ($schema as $name => $table) {
       db_drop_table($name);
     }
@@ -1545,7 +1547,7 @@ class DrupalWebTestCase extends DrupalTestCase {
 
     // Return the user to the original one.
     $user = $this->originalUser;
-    drupal_save_session(TRUE);
+    save_session(TRUE);
 
     // Ensure that internal logged in variable and cURL options are reset.
     $this->loggedInUser = FALSE;
@@ -1607,7 +1609,7 @@ class DrupalWebTestCase extends DrupalTestCase {
     // We set the user agent header on each request so as to use the current
     // time and a new uniqid.
     if (preg_match('/simpletest\d+/', $this->databasePrefix, $matches)) {
-      curl_setopt($this->curlHandle, CURLOPT_USERAGENT, drupal_generate_test_ua($matches[0]));
+      curl_setopt($this->curlHandle, CURLOPT_USERAGENT, generate_test_ua($matches[0]));
     }
   }
 
@@ -1692,7 +1694,7 @@ class DrupalWebTestCase extends DrupalTestCase {
   /**
    * Reads headers and registers errors received from the tested site.
    *
-   * @see _drupal_log_error().
+   * @see _log_error().
    *
    * @param $curlHandler
    *   The cURL handler.
@@ -1712,10 +1714,10 @@ class DrupalWebTestCase extends DrupalTestCase {
     }
 
     // Errors are being sent via X-Drupal-Assertion-* headers,
-    // generated by _drupal_log_error() in the exact form required
-    // by DrupalWebTestCase::error().
+    // generated by _log_error() in the exact form required
+    // by WebTestCase::error().
     if (preg_match('/^X-Drupal-Assertion-[0-9]+: (.*)$/', $header, $matches)) {
-      // Call DrupalWebTestCase::error() with the parameters from the header.
+      // Call WebTestCase::error() with the parameters from the header.
       call_user_func_array(array(&$this, 'error'), unserialize(urldecode($matches[1])));
     }
 
@@ -2080,7 +2082,7 @@ class DrupalWebTestCase extends DrupalTestCase {
       foreach ($return as $command) {
         switch ($command['command']) {
           case 'settings':
-            $drupal_settings = drupal_array_merge_deep($drupal_settings, $command['settings']);
+            $drupal_settings = array_merge_deep($drupal_settings, $command['settings']);
             break;
 
           case 'insert':
@@ -2723,7 +2725,7 @@ class DrupalWebTestCase extends DrupalTestCase {
    * outside of the internal browser and assertions need to be made on the
    * returned page.
    *
-   * A good example would be when testing drupal_http_request(). After fetching
+   * A good example would be when testing http_request(). After fetching
    * the page the content can be set and page elements can be checked to ensure
    * that the function worked properly.
    */
@@ -3498,8 +3500,8 @@ class DrupalWebTestCase extends DrupalTestCase {
  * @return
  *   The ID of the message to be placed in related assertion messages.
  *
- * @see DrupalTestCase->originalFileDirectory
- * @see DrupalWebTestCase->verbose()
+ * @see TestCase->originalFileDirectory
+ * @see WebTestCase->verbose()
  */
 function simpletest_verbose($message, $original_file_directory = NULL, $test_class = NULL) {
   static $file_directory = NULL, $class = NULL, $id = 1, $verbose = NULL;
@@ -3517,7 +3519,7 @@ function simpletest_verbose($message, $original_file_directory = NULL, $test_cla
 
   if ($original_file_directory) {
     $file_directory = $original_file_directory;
-    $class = $test_class;
+    $class = str_replace('\\', '-', $test_class);
     $verbose = variable_get('simpletest_verbose', TRUE);
     $directory = $file_directory . '/simpletest/verbose';
     $writable = file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
diff --git a/core/modules/simpletest/simpletest.api.php b/core/modules/simpletest/simpletest.api.php
index 04c080b..7c0232c 100644
--- a/core/modules/simpletest/simpletest.api.php
+++ b/core/modules/simpletest/simpletest.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -47,9 +48,9 @@ function hook_test_group_finished() {
  * This hook is called when an individual test has finished.
  *
  * @param
- *   $results The results of the test as gathered by DrupalWebTestCase.
+ *   $results The results of the test as gathered by WebTestCase.
  *
- * @see DrupalWebTestCase->results
+ * @see WebTestCase->results
  */
 function hook_test_finished($results) {
 }
diff --git a/core/modules/simpletest/simpletest.install b/core/modules/simpletest/simpletest.install
index 96cc011..c2d4660 100644
--- a/core/modules/simpletest/simpletest.install
+++ b/core/modules/simpletest/simpletest.install
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use DOMDocument;
 
 /**
  * @file
@@ -167,7 +169,7 @@ function simpletest_schema() {
  * Implements hook_uninstall().
  */
 function simpletest_uninstall() {
-  drupal_load('module', 'simpletest');
+  load('module', 'simpletest');
   simpletest_clean_database();
 
   // Remove settings variables.
diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module
index 831ea85..4954aea 100644
--- a/core/modules/simpletest/simpletest.module
+++ b/core/modules/simpletest/simpletest.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -30,7 +31,7 @@ function simpletest_help($path, $arg) {
 function simpletest_menu() {
   $items['admin/config/development/testing'] = array(
     'title' => 'Testing',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('simpletest_test_form'),
     'description' => 'Run tests against Drupal core and your modules. These tests help assure that your site code is working as designed.',
     'access arguments' => array('administer unit tests'),
@@ -43,7 +44,7 @@ function simpletest_menu() {
   );
   $items['admin/config/development/testing/settings'] = array(
     'title' => 'Settings',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('simpletest_settings_form'),
     'access arguments' => array('administer unit tests'),
     'type' => MENU_LOCAL_TASK,
@@ -51,7 +52,7 @@ function simpletest_menu() {
   );
   $items['admin/config/development/testing/results/%'] = array(
     'title' => 'Test result',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('simpletest_result_form', 5),
     'description' => 'View result of tests.',
     'access arguments' => array('administer unit tests'),
@@ -94,7 +95,7 @@ function simpletest_theme() {
 function simpletest_js_alter(&$javascript) {
   // Since SimpleTest is a special use case for the table select, stick the
   // SimpleTest JavaScript above the table select.
-  $simpletest = drupal_get_path('module', 'simpletest') . '/simpletest.js';
+  $simpletest = get_path('module', 'simpletest') . '/simpletest.js';
   if (array_key_exists($simpletest, $javascript) && array_key_exists('core/misc/tableselect.js', $javascript)) {
     $javascript[$simpletest]['weight'] = $javascript['core/misc/tableselect.js']['weight'] - 1;
   }
@@ -132,7 +133,8 @@ function simpletest_run_tests($test_list, $reporter = 'drupal') {
 
   // Get the info for the first test being run.
   $first_test = array_shift($test_list);
-  $first_instance = new $first_test();
+  $class = 'Drupal\\' . $first_test;
+  $first_instance = new $class();
   array_unshift($test_list, $first_test);
   $info = $first_instance->getInfo();
 
@@ -143,7 +145,7 @@ function simpletest_run_tests($test_list, $reporter = 'drupal') {
     ),
     'finished' => '_simpletest_batch_finished',
     'progress_message' => '',
-    'css' => array(drupal_get_path('module', 'simpletest') . '/simpletest.css'),
+    'css' => array(get_path('module', 'simpletest') . '/simpletest.css'),
     'init_message' => t('Processing test @num of @max - %test.', array('%test' => $info['name'], '@num' => '1', '@max' => count($test_list))),
   );
   batch_set($batch);
@@ -172,7 +174,7 @@ function _simpletest_batch_operation($test_list_init, $test_id, &$context) {
   $max = $context['sandbox']['max'];
 
   // Perform the next test.
-  $test_class = array_shift($test_list);
+  $test_class = 'Drupal\\' . array_shift($test_list);
   $test = new $test_class($test_id);
   $test->run();
   $size = count($test_list);
@@ -206,7 +208,7 @@ function _simpletest_batch_operation($test_list_init, $test_id, &$context) {
 
 function _simpletest_batch_finished($success, $results, $operations, $elapsed) {
   if ($success) {
-    drupal_set_message(t('The test run finished in @elapsed.', array('@elapsed' => $elapsed)));
+    set_message(t('The test run finished in @elapsed.', array('@elapsed' => $elapsed)));
   }
   else {
     // Use the test_id passed as a parameter to _simpletest_batch_operation().
@@ -218,8 +220,8 @@ function _simpletest_batch_finished($success, $results, $operations, $elapsed) {
     list($last_prefix, $last_test_class) = simpletest_last_test_get($test_id);
     simpletest_log_read($test_id, $last_prefix, $last_test_class);
 
-    drupal_set_message(t('The test run did not successfully finish.'), 'error');
-    drupal_set_message(t('Use the <em>Clean environment</em> button to clean-up temporary files and tables.'), 'warning');
+    set_message(t('The test run did not successfully finish.'), 'error');
+    set_message(t('Use the <em>Clean environment</em> button to clean-up temporary files and tables.'), 'warning');
   }
   module_invoke_all('test_group_finished');
 }
@@ -269,11 +271,11 @@ function simpletest_log_read($test_id, $prefix, $test_class, $during_test = FALS
           'line' => $match[4],
           'file' => $match[3],
         );
-        DrupalTestCase::insertAssert($test_id, $test_class, FALSE, $match[2], $match[1], $caller);
+        TestCase::insertAssert($test_id, $test_class, FALSE, $match[2], $match[1], $caller);
       }
       else {
         // Unknown format, place the entire message in the log.
-        DrupalTestCase::insertAssert($test_id, $test_class, FALSE, $line, 'Fatal error');
+        TestCase::insertAssert($test_id, $test_class, FALSE, $line, 'Fatal error');
       }
       $found = TRUE;
     }
@@ -323,13 +325,13 @@ function simpletest_test_get_all() {
       $groups = array();
       foreach ($classes as $class) {
         // Test classes need to implement getInfo() to be valid.
-        if (class_exists($class) && method_exists($class, 'getInfo')) {
-          $info = call_user_func(array($class, 'getInfo'));
+        if (class_exists('Drupal\\' . $class) && method_exists('Drupal\\' . $class, 'getInfo')) {
+          $info = call_user_func(array('Drupal\\' . $class, 'getInfo'));
 
           // If this test class requires a non-existing module, skip it.
           if (!empty($info['dependencies'])) {
             foreach ($info['dependencies'] as $module) {
-              if (!drupal_get_filename('module', $module)) {
+              if (!get_filename('module', $module)) {
                 continue 2;
               }
             }
@@ -346,7 +348,7 @@ function simpletest_test_get_all() {
       }
 
       // Allow modules extending core tests to disable originals.
-      drupal_alter('simpletest', $groups);
+      alter('simpletest', $groups);
       cache()->set('simpletest', $groups);
     }
   }
@@ -413,10 +415,10 @@ function simpletest_clean_environment() {
   simpletest_clean_temporary_directories();
   if (variable_get('simpletest_clear_results', TRUE)) {
     $count = simpletest_clean_results_table();
-    drupal_set_message(format_plural($count, 'Removed 1 test result.', 'Removed @count test results.'));
+    set_message(format_plural($count, 'Removed 1 test result.', 'Removed @count test results.'));
   }
   else {
-    drupal_set_message(t('Clear results is disabled and the test results table will not be cleared.'), 'warning');
+    set_message(t('Clear results is disabled and the test results table will not be cleared.'), 'warning');
   }
 
   // Detect test classes that have been added, renamed or deleted.
@@ -429,7 +431,7 @@ function simpletest_clean_environment() {
  */
 function simpletest_clean_database() {
   $tables = db_find_tables(Database::getConnection()->prefixTables('{simpletest}') . '%');
-  $schema = drupal_get_schema_unprocessed('simpletest');
+  $schema = get_schema_unprocessed('simpletest');
   $count = 0;
   foreach (array_diff_key($tables, $schema) as $table) {
     // Strip the prefix and skip tables without digits following "simpletest",
@@ -441,10 +443,10 @@ function simpletest_clean_database() {
   }
 
   if ($count > 0) {
-    drupal_set_message(format_plural($count, 'Removed 1 leftover table.', 'Removed @count leftover tables.'));
+    set_message(format_plural($count, 'Removed 1 leftover table.', 'Removed @count leftover tables.'));
   }
   else {
-    drupal_set_message(t('No leftover tables to remove.'));
+    set_message(t('No leftover tables to remove.'));
   }
 }
 
@@ -465,10 +467,10 @@ function simpletest_clean_temporary_directories() {
   }
 
   if ($count > 0) {
-    drupal_set_message(format_plural($count, 'Removed 1 temporary directory.', 'Removed @count temporary directories.'));
+    set_message(format_plural($count, 'Removed 1 temporary directory.', 'Removed @count temporary directories.'));
   }
   else {
-    drupal_set_message(t('No temporary directories to remove.'));
+    set_message(t('No temporary directories to remove.'));
   }
 }
 
diff --git a/core/modules/simpletest/simpletest.pages.inc b/core/modules/simpletest/simpletest.pages.inc
index 8ac1ee2..e754212 100644
--- a/core/modules/simpletest/simpletest.pages.inc
+++ b/core/modules/simpletest/simpletest.pages.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -68,9 +70,9 @@ function simpletest_test_form($form) {
 function theme_simpletest_test_table($variables) {
   $table = $variables['table'];
 
-  drupal_add_css(drupal_get_path('module', 'simpletest') . '/simpletest.css');
-  drupal_add_js(drupal_get_path('module', 'simpletest') . '/simpletest.js');
-  drupal_add_js('core/misc/tableselect.js');
+  add_css(get_path('module', 'simpletest') . '/simpletest.css');
+  add_js(get_path('module', 'simpletest') . '/simpletest.js');
+  add_js('core/misc/tableselect.js');
 
   // Create header for test selection table.
   $header = array(
@@ -128,7 +130,7 @@ function theme_simpletest_test_table($variables) {
     );
 
     // Sorting $element by children's #title attribute instead of by class name.
-    uasort($element, 'element_sort_by_title');
+    uasort($element, 'Drupal\element_sort_by_title');
 
     // Cycle through each test within the current group.
     foreach (element_children($element) as $test_name) {
@@ -167,7 +169,7 @@ function theme_simpletest_test_table($variables) {
   }
 
   // Add js array of settings.
-  drupal_add_js(array('simpleTest' => $js), 'setting');
+  add_js(array('simpleTest' => $js), 'setting');
 
   if (empty($rows)) {
     return '<strong>' . t('No tests to display.') . '</strong>';
@@ -186,7 +188,7 @@ function simpletest_test_form_submit($form, &$form_state) {
   foreach ($form_state['values'] as $class_name => $value) {
     // Since class_exists() will likely trigger an autoload lookup,
     // we do the fast check first.
-    if ($value === 1 && class_exists($class_name)) {
+    if ($value === 1 && class_exists('Drupal\\' . $class_name)) {
       $tests_list[] = $class_name;
     }
   }
@@ -195,7 +197,7 @@ function simpletest_test_form_submit($form, &$form_state) {
     $form_state['redirect'] = 'admin/config/development/testing/results/' . $test_id;
   }
   else {
-    drupal_set_message(t('No test(s) selected.'), 'error');
+    set_message(t('No test(s) selected.'), 'error');
   }
 }
 
@@ -206,13 +208,13 @@ function simpletest_result_form($form, &$form_state, $test_id) {
   // Make sure there are test results to display and a re-run is not being performed.
   $results = array();
   if (is_numeric($test_id) && !$results = simpletest_result_get($test_id)) {
-    drupal_set_message(t('No test results to display.'), 'error');
-    drupal_goto('admin/config/development/testing');
+    set_message(t('No test results to display.'), 'error');
+    redirect('admin/config/development/testing');
     return $form;
   }
 
   // Load all classes and include CSS.
-  drupal_add_css(drupal_get_path('module', 'simpletest') . '/simpletest.css');
+  add_css(get_path('module', 'simpletest') . '/simpletest.css');
 
   // Keep track of which test cases passed or failed.
   $filter = array(
@@ -254,9 +256,9 @@ function simpletest_result_form($form, &$form_state, $test_id) {
       $row = array();
       $row[] = $assertion->message;
       $row[] = $assertion->message_group;
-      $row[] = drupal_basename($assertion->file);
+      $row[] = basename($assertion->file);
       $row[] = $assertion->line;
-      $row[] = $assertion->function;
+      $row[] = substr($assertion->function, 7);
       $row[] = simpletest_result_status_image($assertion->status);
 
       $class = 'simpletest-' . $assertion->status;
@@ -357,7 +359,7 @@ function simpletest_result_form_submit($form, &$form_state) {
 
   $form_state_execute = array('values' => array());
   foreach ($classes as $class) {
-    $form_state_execute['values'][$class] = 1;
+    $form_state_execute['values'][substr($class, 7)] = 1;
   }
 
   simpletest_test_form_submit(array(), $form_state_execute);
diff --git a/core/modules/simpletest/simpletest.test b/core/modules/simpletest/simpletest.test
index bd4427c..9bf78d6 100644
--- a/core/modules/simpletest/simpletest.test
+++ b/core/modules/simpletest/simpletest.test
@@ -1,11 +1,13 @@
 <?php
+namespace Drupal;
+use SimpleXMLElement;
 
 /**
  * @file
  * Tests for simpletest.module.
  */
 
-class SimpleTestFunctionalTest extends DrupalWebTestCase {
+class SimpleTestFunctionalTest extends WebTestCase {
   /**
    * The results array that has been parsed by getTestResults().
    */
@@ -84,12 +86,12 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
   function testUserAgentValidation() {
     if (!$this->inCURL()) {
       global $base_url;
-      $simpletest_path = $base_url . '/' . drupal_get_path('module', 'simpletest');
+      $simpletest_path = $base_url . '/' . get_path('module', 'simpletest');
       $HTTP_path = $simpletest_path .'/tests/http.php?q=node';
       $https_path = $simpletest_path .'/tests/https.php?q=node';
       // Generate a valid simpletest User-Agent to pass validation.
       $this->assertTrue(preg_match('/simpletest\d+/', $this->databasePrefix, $matches), t('Database prefix contains simpletest prefix.'));
-      $test_ua = drupal_generate_test_ua($matches[0]);
+      $test_ua = generate_test_ua($matches[0]);
       $this->additionalCurlOptions = array(CURLOPT_USERAGENT => $test_ua);
 
       // Test pages only available for testing.
@@ -314,14 +316,14 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
    * Check if the test is being run from inside a CURL request.
    */
   function inCURL() {
-    return (bool) drupal_valid_test_ua();
+    return (bool) valid_test_ua();
   }
 }
 
 /**
  * Test internal testing framework browser.
  */
-class SimpleTestBrowserTestCase extends DrupalWebTestCase {
+class SimpleTestBrowserTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'SimpleTest browser',
@@ -336,7 +338,7 @@ class SimpleTestBrowserTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Test DrupalWebTestCase::getAbsoluteUrl().
+   * Test WebTestCase::getAbsoluteUrl().
    */
   function testGetAbsoluteUrl() {
     // Testbed runs with Clean URLs disabled, so disable it here.
@@ -382,7 +384,7 @@ EOF;
   }
 }
 
-class SimpleTestMailCaptureTestCase extends DrupalWebTestCase {
+class SimpleTestMailCaptureTestCase extends WebTestCase {
   /**
    * Implement getInfo().
    */
@@ -402,7 +404,7 @@ class SimpleTestMailCaptureTestCase extends DrupalWebTestCase {
     $subject = $this->randomString(64);
     $body = $this->randomString(128);
     $message = array(
-      'id' => 'drupal_mail_test',
+      'id' => 'mail_test',
       'headers' => array('Content-type'=> 'text/html'),
       'subject' => $subject,
       'to' => 'foobar@example.com',
@@ -414,7 +416,7 @@ class SimpleTestMailCaptureTestCase extends DrupalWebTestCase {
     $this->assertEqual(count($captured_emails), 0, t('The captured e-mails queue is empty.'), t('E-mail'));
 
     // Send the e-mail.
-    $response = drupal_mail_system('simpletest', 'drupal_mail_test')->mail($message);
+    $response = mail_system('simpletest', 'mail_test')->mail($message);
 
     // Ensure that there is one e-mail in the captured e-mails array.
     $captured_emails = $this->drupalGetMails();
@@ -429,13 +431,13 @@ class SimpleTestMailCaptureTestCase extends DrupalWebTestCase {
     // Send additional e-mails so more than one e-mail is captured.
     for ($index = 0; $index < 5; $index++) {
       $message = array(
-        'id' => 'drupal_mail_test_' . $index,
+        'id' => 'mail_test_' . $index,
         'headers' => array('Content-type'=> 'text/html'),
         'subject' => $this->randomString(64),
         'to' => $this->randomName(32) . '@example.com',
         'body' => $this->randomString(512),
       );
-      drupal_mail_system('drupal_mail_test', $index)->mail($message);
+      mail_system('mail_test', $index)->mail($message);
     }
 
     // There should now be 6 e-mails captured.
@@ -443,17 +445,17 @@ class SimpleTestMailCaptureTestCase extends DrupalWebTestCase {
     $this->assertEqual(count($captured_emails), 6, t('All e-mails were captured.'), t('E-mail'));
 
     // Test different ways of getting filtered e-mails via drupalGetMails().
-    $captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test'));
+    $captured_emails = $this->drupalGetMails(array('id' => 'mail_test'));
     $this->assertEqual(count($captured_emails), 1, t('Only one e-mail is returned when filtering by id.'), t('E-mail'));
-    $captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test', 'subject' => $subject));
+    $captured_emails = $this->drupalGetMails(array('id' => 'mail_test', 'subject' => $subject));
     $this->assertEqual(count($captured_emails), 1, t('Only one e-mail is returned when filtering by id and subject.'), t('E-mail'));
-    $captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test', 'subject' => $subject, 'from' => 'this_was_not_used@example.com'));
+    $captured_emails = $this->drupalGetMails(array('id' => 'mail_test', 'subject' => $subject, 'from' => 'this_was_not_used@example.com'));
     $this->assertEqual(count($captured_emails), 0, t('No e-mails are returned when querying with an unused from address.'), t('E-mail'));
 
     // Send the last e-mail again, so we can confirm that the drupalGetMails-filter
     // correctly returns all e-mails with a given property/value.
-    drupal_mail_system('drupal_mail_test', $index)->mail($message);
-    $captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test_4'));
+    mail_system('mail_test', $index)->mail($message);
+    $captured_emails = $this->drupalGetMails(array('id' => 'mail_test_4'));
     $this->assertEqual(count($captured_emails), 2, t('All e-mails with the same id are returned when filtering by id.'), t('E-mail'));
   }
 }
@@ -461,7 +463,7 @@ class SimpleTestMailCaptureTestCase extends DrupalWebTestCase {
 /**
  * Test Folder creation
  */
-class SimpleTestFolderTestCase extends DrupalWebTestCase {
+class SimpleTestFolderTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Testing SimpleTest setUp',
@@ -483,7 +485,7 @@ class SimpleTestFolderTestCase extends DrupalWebTestCase {
 /**
  * Test required modules for tests.
  */
-class SimpleTestMissingDependentModuleUnitTest extends DrupalUnitTestCase {
+class SimpleTestMissingDependentModuleUnitTest extends UnitTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Testing dependent module test',
@@ -505,12 +507,12 @@ class SimpleTestMissingDependentModuleUnitTest extends DrupalUnitTestCase {
  * Tests a test case that does not run parent::setUp() in its setUp() method.
  *
  * If a test case does not call parent::setUp(), running
- * DrupalTestCase::tearDown() would destroy the main site's database tables.
+ * TestCase::tearDown() would destroy the main site's database tables.
  * Therefore, we ensure that tests which are not set up properly are skipped.
  *
- * @see DrupalTestCase
+ * @see TestCase
  */
-class SimpleTestBrokenSetUp extends DrupalWebTestCase {
+class SimpleTestBrokenSetUp extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Broken SimpleTest method',
@@ -521,7 +523,7 @@ class SimpleTestBrokenSetUp extends DrupalWebTestCase {
 
   function setUp() {
     // If the test is being run from the main site, set up normally.
-    if (!drupal_valid_test_ua()) {
+    if (!valid_test_ua()) {
       parent::setUp('simpletest');
       // Create and log in user.
       $admin_user = $this->drupalCreateUser(array('administer unit tests'));
@@ -536,7 +538,7 @@ class SimpleTestBrokenSetUp extends DrupalWebTestCase {
 
   function tearDown() {
     // If the test is being run from the main site, tear down normally.
-    if (!drupal_valid_test_ua()) {
+    if (!valid_test_ua()) {
       parent::tearDown();
     }
     else {
@@ -551,7 +553,7 @@ class SimpleTestBrokenSetUp extends DrupalWebTestCase {
   function testBreakSetUp() {
     // If the test is being run from the main site, run it again from the web
     // interface within the simpletest child site.
-    if (!drupal_valid_test_ua()) {
+    if (!valid_test_ua()) {
       $edit['SimpleTestBrokenSetUp'] = TRUE;
       $this->drupalPost('admin/config/development/testing', $edit, t('Run tests'));
 
@@ -571,7 +573,7 @@ class SimpleTestBrokenSetUp extends DrupalWebTestCase {
 /**
  * Tests missing requirements to run test.
  */
-class SimpleTestMissingCheckedRequirements extends DrupalWebTestCase {
+class SimpleTestMissingCheckedRequirements extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Broken requirements test',
@@ -590,7 +592,7 @@ class SimpleTestMissingCheckedRequirements extends DrupalWebTestCase {
    * Overrides checkRequirements().
    */
   protected function checkRequirements() {
-    if (drupal_valid_test_ua()) {
+    if (valid_test_ua()) {
       return array(
         'Test is not allowed to run.'
       );
@@ -604,7 +606,7 @@ class SimpleTestMissingCheckedRequirements extends DrupalWebTestCase {
   protected function testCheckRequirements() {
     // If this is the main request, run the web test script and then assert
     // that the child tests did not run.
-    if (!drupal_valid_test_ua()) {
+    if (!valid_test_ua()) {
       // Run this test from web interface.
       $edit['SimpleTestMissingCheckedRequirements'] = TRUE;
       $this->drupalPost('admin/config/development/testing', $edit, t('Run tests'));
diff --git a/core/modules/simpletest/tests/actions.test b/core/modules/simpletest/tests/actions.test
index afcb686..c080699 100644
--- a/core/modules/simpletest/tests/actions.test
+++ b/core/modules/simpletest/tests/actions.test
@@ -1,6 +1,7 @@
 <?php
+namespace Drupal;
 
-class ActionsConfigurationTestCase extends DrupalWebTestCase {
+class ActionsConfigurationTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Actions configuration',
@@ -20,7 +21,7 @@ class ActionsConfigurationTestCase extends DrupalWebTestCase {
 
     // Make a POST request to admin/config/system/actions/manage.
     $edit = array();
-    $edit['action'] = drupal_hash_base64('system_goto_action');
+    $edit['action'] = hash_base64('system_redirect_action');
     $this->drupalPost('admin/config/system/actions/manage', $edit, t('Create'));
 
     // Make a POST request to the individual action configuration page.
@@ -28,7 +29,7 @@ class ActionsConfigurationTestCase extends DrupalWebTestCase {
     $action_label = $this->randomName();
     $edit['actions_label'] = $action_label;
     $edit['url'] = 'admin';
-    $this->drupalPost('admin/config/system/actions/configure/' . drupal_hash_base64('system_goto_action'), $edit, t('Save'));
+    $this->drupalPost('admin/config/system/actions/configure/' . hash_base64('system_redirect_action'), $edit, t('Save'));
 
     // Make sure that the new complex action was saved properly.
     $this->assertText(t('The action has been successfully saved.'), t("Make sure we get a confirmation that we've successfully saved the complex action."));
@@ -58,7 +59,7 @@ class ActionsConfigurationTestCase extends DrupalWebTestCase {
     $this->assertRaw(t('Action %action was deleted', array('%action' => $new_action_label)), t('Make sure that we get a delete confirmation message.'));
     $this->drupalGet('admin/config/system/actions/manage');
     $this->assertNoText($new_action_label, t("Make sure the action label does not appear on the overview page after we've deleted the action."));
-    $exists = db_query('SELECT aid FROM {actions} WHERE callback = :callback', array(':callback' => 'drupal_goto_action'))->fetchField();
+    $exists = db_query('SELECT aid FROM {actions} WHERE callback = :callback', array(':callback' => 'redirect_action'))->fetchField();
     $this->assertFalse($exists, t('Make sure the action is gone from the database after being deleted.'));
   }
 }
@@ -66,7 +67,7 @@ class ActionsConfigurationTestCase extends DrupalWebTestCase {
 /**
  * Test actions executing in a potential loop, and make sure they abort properly.
  */
-class ActionLoopTestCase extends DrupalWebTestCase {
+class ActionLoopTestCase extends WebTestCase {
   protected $aid;
 
   public static function getInfo() {
diff --git a/core/modules/simpletest/tests/actions_loop_test.install b/core/modules/simpletest/tests/actions_loop_test.install
index b22fd85..a0279c1 100644
--- a/core/modules/simpletest/tests/actions_loop_test.install
+++ b/core/modules/simpletest/tests/actions_loop_test.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Implements hook_install().
diff --git a/core/modules/simpletest/tests/actions_loop_test.module b/core/modules/simpletest/tests/actions_loop_test.module
index 66516b6..6c87a24 100644
--- a/core/modules/simpletest/tests/actions_loop_test.module
+++ b/core/modules/simpletest/tests/actions_loop_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Implements hook_watchdog().
diff --git a/core/modules/simpletest/tests/ajax.test b/core/modules/simpletest/tests/ajax.test
index 8e731b8..92759a8 100644
--- a/core/modules/simpletest/tests/ajax.test
+++ b/core/modules/simpletest/tests/ajax.test
@@ -1,6 +1,7 @@
 <?php
+namespace Drupal;
 
-class AJAXTestCase extends DrupalWebTestCase {
+class AJAXTestCase extends WebTestCase {
   function setUp() {
     $modules = func_get_args();
     if (isset($modules[0]) && is_array($modules[0])) {
@@ -79,12 +80,12 @@ class AJAXFrameworkTestCase extends AJAXTestCase {
     $commands = $this->drupalGetAJAX('ajax-test/render');
 
     // Verify that there is a command to load settings added with
-    // drupal_add_js().
+    // add_js().
     $expected = array(
       'command' => 'settings',
       'settings' => array('basePath' => base_path(), 'ajax' => 'test'),
     );
-    $this->assertCommand($commands, $expected, t('ajax_render() loads settings added with drupal_add_js().'));
+    $this->assertCommand($commands, $expected, t('ajax_render() loads settings added with add_js().'));
 
     // Verify that Ajax settings are loaded for #type 'link'.
     $this->drupalGet('ajax-test/link');
@@ -124,11 +125,11 @@ class AJAXFrameworkTestCase extends AJAXTestCase {
     $expected = array(
       'setting_name' => 'ajax_forms_test_lazy_load_form_submit',
       'setting_value' => 'executed',
-      'css' => drupal_get_path('module', 'system') . '/system.admin.css',
-      'js' => drupal_get_path('module', 'system') . '/system.js',
+      'css' => get_path('module', 'system') . '/system.admin.css',
+      'js' => get_path('module', 'system') . '/system.js',
     );
     // @todo D8: Add a drupal_css_defaults() helper function.
-    $expected_css_html = drupal_get_css(array($expected['css'] => array(
+    $expected_css_html = get_css(array($expected['css'] => array(
       'type' => 'file',
       'group' => CSS_DEFAULT,
       'weight' => 0,
@@ -138,7 +139,7 @@ class AJAXFrameworkTestCase extends AJAXTestCase {
       'data' => $expected['css'],
       'browsers' => array('IE' => TRUE, '!IE' => TRUE),
     )), TRUE);
-    $expected_js_html = drupal_get_js('header', array($expected['js'] => drupal_js_defaults($expected['js'])), TRUE);
+    $expected_js_html = get_js('header', array($expected['js'] => js_defaults($expected['js'])), TRUE);
 
     // Get the base page.
     $this->drupalGet('ajax_forms_test_lazy_load_form');
diff --git a/core/modules/simpletest/tests/ajax_forms_test.module b/core/modules/simpletest/tests/ajax_forms_test.module
index 6a95710..c474941 100644
--- a/core/modules/simpletest/tests/ajax_forms_test.module
+++ b/core/modules/simpletest/tests/ajax_forms_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -13,25 +14,25 @@ function ajax_forms_test_menu() {
   $items = array();
   $items['ajax_forms_test_get_form'] = array(
     'title' => 'AJAX forms simple form test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('ajax_forms_test_simple_form'),
     'access callback' => TRUE,
   );
   $items['ajax_forms_test_ajax_commands_form'] = array(
     'title' => 'AJAX forms AJAX commands test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('ajax_forms_test_ajax_commands_form'),
     'access callback' => TRUE,
   );
   $items['ajax_validation_test'] = array(
     'title' => 'AJAX Validation Test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('ajax_forms_test_validation_form'),
     'access callback' => TRUE,
   );
   $items['ajax_forms_test_lazy_load_form'] = array(
     'title' => 'AJAX forms lazy load test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('ajax_forms_test_lazy_load_form'),
     'access callback' => TRUE,
   );
@@ -452,15 +453,15 @@ function ajax_forms_test_validation_form($form, &$form_state) {
  * Submit handler for the validation form.
  */
 function ajax_forms_test_validation_form_submit($form, $form_state) {
-  drupal_set_message(t("Validation form submitted"));
+  set_message(t("Validation form submitted"));
 }
 
 /**
  * Ajax callback for the 'drivertext' element of the validation form.
  */
 function ajax_forms_test_validation_form_callback($form, $form_state) {
-  drupal_set_message("ajax_forms_test_validation_form_callback invoked");
-  drupal_set_message(t("Callback: drivertext=%drivertext, spare_required_field=%spare_required_field", array('%drivertext' => $form_state['values']['drivertext'], '%spare_required_field' => $form_state['values']['spare_required_field'])));
+  set_message("ajax_forms_test_validation_form_callback invoked");
+  set_message(t("Callback: drivertext=%drivertext, spare_required_field=%spare_required_field", array('%drivertext' => $form_state['values']['drivertext'], '%spare_required_field' => $form_state['values']['spare_required_field'])));
   return '<div id="message_area">ajax_forms_test_validation_form_callback at ' . date('c') . '</div>';
 }
 
@@ -487,9 +488,9 @@ function ajax_forms_test_lazy_load_form($form, &$form_state) {
  */
 function ajax_forms_test_lazy_load_form_submit($form, &$form_state) {
   if ($form_state['values']['add_files']) {
-    drupal_add_js(array('ajax_forms_test_lazy_load_form_submit' => 'executed'), 'setting');
-    drupal_add_css(drupal_get_path('module', 'system') . '/system.admin.css');
-    drupal_add_js(drupal_get_path('module', 'system') . '/system.js');
+    add_js(array('ajax_forms_test_lazy_load_form_submit' => 'executed'), 'setting');
+    add_css(get_path('module', 'system') . '/system.admin.css');
+    add_js(get_path('module', 'system') . '/system.js');
   }
   $form_state['rebuild'] = TRUE;
 }
diff --git a/core/modules/simpletest/tests/ajax_test.module b/core/modules/simpletest/tests/ajax_test.module
index 4148a08..5337edb 100644
--- a/core/modules/simpletest/tests/ajax_test.module
+++ b/core/modules/simpletest/tests/ajax_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -35,11 +36,11 @@ function ajax_test_menu() {
  * Menu callback; Return an element suitable for use by ajax_deliver().
  *
  * Additionally ensures that ajax_render() incorporates JavaScript settings
- * generated during the page request by invoking drupal_add_js() with a dummy
+ * generated during the page request by invoking add_js() with a dummy
  * setting.
  */
 function ajax_test_render() {
-  drupal_add_js(array('ajax' => 'test'), 'setting');
+  add_js(array('ajax' => 'test'), 'setting');
   return array('#type' => 'ajax', '#commands' => array());
 }
 
diff --git a/core/modules/simpletest/tests/batch.test b/core/modules/simpletest/tests/batch.test
index 1e9b31b..34e83ca 100644
--- a/core/modules/simpletest/tests/batch.test
+++ b/core/modules/simpletest/tests/batch.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -8,7 +9,7 @@
 /**
  * Tests for the Batch API.
  */
-class BatchProcessingTestCase extends DrupalWebTestCase {
+class BatchProcessingTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Batch processing',
@@ -127,14 +128,14 @@ class BatchProcessingTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Test that drupal_form_submit() can run within a batch operation.
+   * Test that form_submit() can run within a batch operation.
    */
   function testDrupalFormSubmitInBatch() {
     // Displaying the page triggers a batch that programmatically submits a
     // form.
     $value = rand(0, 255);
     $this->drupalGet('batch-test/nested-programmatic/' . $value);
-    $this->assertEqual(batch_test_stack(), array('mock form submitted with value = ' . $value), t('drupal_form_submit() ran successfully within a batch operation.'));
+    $this->assertEqual(batch_test_stack(), array('mock form submitted with value = ' . $value), t('form_submit() ran successfully within a batch operation.'));
   }
 
   /**
@@ -277,7 +278,7 @@ class BatchProcessingTestCase extends DrupalWebTestCase {
 /**
  * Tests for the Batch API Progress page.
  */
-class BatchPageTestCase extends DrupalWebTestCase {
+class BatchPageTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Batch progress page',
@@ -316,7 +317,7 @@ class BatchPageTestCase extends DrupalWebTestCase {
  * Tests the function _batch_api_percentage() to make sure that the rounding
  * works properly in all cases.
  */
-class BatchPercentagesUnitTestCase extends DrupalUnitTestCase {
+class BatchPercentagesUnitTestCase extends UnitTestCase {
   protected $testCases = array();
 
   public static function getInfo() {
@@ -379,7 +380,7 @@ class BatchPercentagesUnitTestCase extends DrupalUnitTestCase {
       '80' => array('total' => 1, 'current' => 400/501),
       '99.8' => array('total' => 1, 'current' => 500/501),
     );
-    require_once DRUPAL_ROOT . '/core/includes/batch.inc';
+    require_once ROOT . '/core/includes/batch.inc';
     parent::setUp();
   }
 
diff --git a/core/modules/simpletest/tests/batch_test.callbacks.inc b/core/modules/simpletest/tests/batch_test.callbacks.inc
index 75e6655..0962422 100644
--- a/core/modules/simpletest/tests/batch_test.callbacks.inc
+++ b/core/modules/simpletest/tests/batch_test.callbacks.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 
 /**
@@ -95,7 +96,7 @@ function _batch_test_finished_helper($batch_id, $success, $results, $operations)
     $messages[] = t('An error occurred while processing @op with arguments:<br/>@args', array('@op' => $error_operation[0], '@args' => print_r($error_operation[1], TRUE)));
   }
 
-  drupal_set_message(implode('<br />', $messages));
+  set_message(implode('<br />', $messages));
 }
 
 /**
diff --git a/core/modules/simpletest/tests/batch_test.module b/core/modules/simpletest/tests/batch_test.module
index 1200e76..995d8e1 100644
--- a/core/modules/simpletest/tests/batch_test.module
+++ b/core/modules/simpletest/tests/batch_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -13,7 +14,7 @@ function batch_test_menu() {
 
   $items['batch-test'] = array(
     'title' => 'Batch test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('batch_test_simple_form'),
     'access callback' => TRUE,
   );
@@ -26,7 +27,7 @@ function batch_test_menu() {
   // Multistep form: two steps, each setting a batch.
   $items['batch-test/multistep'] = array(
     'title' => 'Multistep',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('batch_test_multistep_form'),
     'access callback' => TRUE,
     'type' => MENU_LOCAL_TASK,
@@ -35,14 +36,14 @@ function batch_test_menu() {
   // Chained form: four submit handlers, several of which set a batch.
   $items['batch-test/chained'] = array(
     'title' => 'Chained',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('batch_test_chained_form'),
     'access callback' => TRUE,
     'type' => MENU_LOCAL_TASK,
     'weight' => 2,
   );
   // Programmatic form: the page submits the 'Chained' form through
-  // drupal_form_submit().
+  // form_submit().
   $items['batch-test/programmatic'] = array(
     'title' => 'Programmatic',
     'page callback' => 'batch_test_programmatic',
@@ -69,7 +70,7 @@ function batch_test_menu() {
   // Tests programmatic form submission within a batch operation.
   $items['batch-test/nested-programmatic'] = array(
     'title' => 'Nested programmatic',
-    'page callback' => 'batch_test_nested_drupal_form_submit',
+    'page callback' => 'batch_test_nested_form_submit',
     'access callback' => TRUE,
     'type' => MENU_LOCAL_TASK,
     'weight' => 6,
@@ -121,7 +122,7 @@ function batch_test_simple_form() {
 function batch_test_simple_form_submit($form, &$form_state) {
   batch_test_stack(NULL, TRUE);
 
-  $function = '_batch_test_' . $form_state['values']['batch'];
+  $function = 'Drupal\_batch_test_' . $form_state['values']['batch'];
   batch_set($function());
 
   $form_state['redirect'] = 'batch-test/redirect';
@@ -260,28 +261,28 @@ function batch_test_programmatic($value = 1) {
   $form_state = array(
     'values' => array('value' => $value)
   );
-  drupal_form_submit('batch_test_chained_form', $form_state);
+  form_submit('batch_test_chained_form', $form_state);
   return 'Got out of a programmatic batched form.';
 }
 
 /**
  * Menu callback: programmatically submits a form within a batch.
  */
-function batch_test_nested_drupal_form_submit($value = 1) {
+function batch_test_nested_form_submit($value = 1) {
   // Set the batch and process it.
   $batch['operations'] = array(
-    array('_batch_test_nested_drupal_form_submit_callback', array($value)),
+    array('_batch_test_nested_form_submit_callback', array($value)),
   );
   batch_set($batch);
   batch_process('batch-test/redirect');
 }
 
 /**
- * Batch operation: submits form_test_mock_form using drupal_form_submit().
+ * Batch operation: submits form_test_mock_form using form_submit().
  */
-function _batch_test_nested_drupal_form_submit_callback($value) {
+function _batch_test_nested_form_submit_callback($value) {
   $state['values']['test_value'] = $value;
-  drupal_form_submit('batch_test_mock_form', $state);
+  form_submit('batch_test_mock_form', $state);
 }
 
 /**
@@ -340,7 +341,7 @@ function _batch_test_batch_0() {
   $batch = array(
     'operations' => array(),
     'finished' => '_batch_test_finished_0',
-    'file' => drupal_get_path('module', 'batch_test'). '/batch_test.callbacks.inc',
+    'file' => get_path('module', 'batch_test'). '/batch_test.callbacks.inc',
   );
   return $batch;
 }
@@ -362,7 +363,7 @@ function _batch_test_batch_1() {
   $batch = array(
     'operations' => $operations,
     'finished' => '_batch_test_finished_1',
-    'file' => drupal_get_path('module', 'batch_test'). '/batch_test.callbacks.inc',
+    'file' => get_path('module', 'batch_test'). '/batch_test.callbacks.inc',
   );
   return $batch;
 }
@@ -383,7 +384,7 @@ function _batch_test_batch_2() {
   $batch = array(
     'operations' => $operations,
     'finished' => '_batch_test_finished_2',
-    'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
+    'file' => get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
   );
   return $batch;
 }
@@ -414,7 +415,7 @@ function _batch_test_batch_3() {
   $batch = array(
     'operations' => $operations,
     'finished' => '_batch_test_finished_3',
-    'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
+    'file' => get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
   );
   return $batch;
 }
@@ -443,7 +444,7 @@ function _batch_test_batch_4() {
   $batch = array(
     'operations' => $operations,
     'finished' => '_batch_test_finished_4',
-    'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
+    'file' => get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
   );
   return $batch;
 }
@@ -465,7 +466,7 @@ function _batch_test_batch_5() {
   $batch = array(
     'operations' => $operations,
     'finished' => '_batch_test_finished_5',
-    'file' => drupal_get_path('module', 'batch_test'). '/batch_test.callbacks.inc',
+    'file' => get_path('module', 'batch_test'). '/batch_test.callbacks.inc',
   );
   return $batch;
 }
diff --git a/core/modules/simpletest/tests/bootstrap.test b/core/modules/simpletest/tests/bootstrap.test
index 13fdf07..93be16c 100644
--- a/core/modules/simpletest/tests/bootstrap.test
+++ b/core/modules/simpletest/tests/bootstrap.test
@@ -1,6 +1,7 @@
 <?php
+namespace Drupal;
 
-class BootstrapIPAddressTestCase extends DrupalWebTestCase {
+class BootstrapIPAddressTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -20,7 +21,7 @@ class BootstrapIPAddressTestCase extends DrupalWebTestCase {
     $this->cluster_ip = '127.0.0.5';
     $this->untrusted_ip = '0.0.0.0';
 
-    drupal_static_reset('ip_address');
+    drupal_static_reset('Drupal\ip_address');
 
     $_SERVER['REMOTE_ADDR'] = $this->remote_ip;
     unset($_SERVER['HTTP_X_FORWARDED_FOR']);
@@ -31,7 +32,7 @@ class BootstrapIPAddressTestCase extends DrupalWebTestCase {
 
   function tearDown() {
     $_SERVER = $this->oldserver;
-    drupal_static_reset('ip_address');
+    drupal_static_reset('Drupal\ip_address');
     parent::tearDown();
   }
 
@@ -54,7 +55,7 @@ class BootstrapIPAddressTestCase extends DrupalWebTestCase {
 
     // Proxy forwarding on and proxy address not trusted.
     variable_set('reverse_proxy_addresses', array($this->proxy_ip, $this->proxy2_ip));
-    drupal_static_reset('ip_address');
+    drupal_static_reset('Drupal\ip_address');
     $_SERVER['REMOTE_ADDR'] = $this->untrusted_ip;
     $this->assertTrue(
       ip_address() == $this->untrusted_ip,
@@ -64,7 +65,7 @@ class BootstrapIPAddressTestCase extends DrupalWebTestCase {
     // Proxy forwarding on and proxy address trusted.
     $_SERVER['REMOTE_ADDR'] = $this->proxy_ip;
     $_SERVER['HTTP_X_FORWARDED_FOR'] = $this->forwarded_ip;
-    drupal_static_reset('ip_address');
+    drupal_static_reset('Drupal\ip_address');
     $this->assertTrue(
       ip_address() == $this->forwarded_ip,
       t('Proxy forwarding with trusted proxy got forwarded IP address.')
@@ -73,7 +74,7 @@ class BootstrapIPAddressTestCase extends DrupalWebTestCase {
     // Multi-tier architecture with comma separated values in header.
     $_SERVER['REMOTE_ADDR'] = $this->proxy_ip;
     $_SERVER['HTTP_X_FORWARDED_FOR'] = implode(', ', array($this->untrusted_ip, $this->forwarded_ip, $this->proxy2_ip));
-    drupal_static_reset('ip_address');
+    drupal_static_reset('Drupal\ip_address');
     $this->assertTrue(
       ip_address() == $this->forwarded_ip,
       t('Proxy forwarding with trusted 2-tier proxy got forwarded IP address.')
@@ -82,23 +83,23 @@ class BootstrapIPAddressTestCase extends DrupalWebTestCase {
     // Custom client-IP header.
     variable_set('reverse_proxy_header', 'HTTP_X_CLUSTER_CLIENT_IP');
     $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'] = $this->cluster_ip;
-    drupal_static_reset('ip_address');
+    drupal_static_reset('Drupal\ip_address');
     $this->assertTrue(
       ip_address() == $this->cluster_ip,
       t('Cluster environment got cluster client IP.')
     );
 
-    // Verifies that drupal_valid_http_host() prevents invalid characters.
-    $this->assertFalse(drupal_valid_http_host('security/.drupal.org:80'), t('HTTP_HOST with / is invalid'));
-    $this->assertFalse(drupal_valid_http_host('security\\.drupal.org:80'), t('HTTP_HOST with \\ is invalid'));
-    $this->assertFalse(drupal_valid_http_host('security<.drupal.org:80'), t('HTTP_HOST with &lt; is invalid'));
-    $this->assertFalse(drupal_valid_http_host('security..drupal.org:80'), t('HTTP_HOST with .. is invalid'));
+    // Verifies that valid_http_host() prevents invalid characters.
+    $this->assertFalse(valid_http_host('security/.drupal.org:80'), t('HTTP_HOST with / is invalid'));
+    $this->assertFalse(valid_http_host('security\\.drupal.org:80'), t('HTTP_HOST with \\ is invalid'));
+    $this->assertFalse(valid_http_host('security<.drupal.org:80'), t('HTTP_HOST with &lt; is invalid'));
+    $this->assertFalse(valid_http_host('security..drupal.org:80'), t('HTTP_HOST with .. is invalid'));
     // IPv6 loopback address
-    $this->assertTrue(drupal_valid_http_host('[::1]:80'), t('HTTP_HOST containing IPv6 loopback is valid'));
+    $this->assertTrue(valid_http_host('[::1]:80'), t('HTTP_HOST containing IPv6 loopback is valid'));
   }
 }
 
-class BootstrapPageCacheTestCase extends DrupalWebTestCase {
+class BootstrapPageCacheTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -222,7 +223,7 @@ class BootstrapPageCacheTestCase extends DrupalWebTestCase {
   }
 }
 
-class BootstrapVariableTestCase extends DrupalWebTestCase {
+class BootstrapVariableTestCase extends WebTestCase {
 
   function setUp() {
     parent::setUp('system_test');
@@ -272,7 +273,7 @@ class BootstrapVariableTestCase extends DrupalWebTestCase {
 /**
  * Test hook_boot() and hook_exit().
  */
-class HookBootExitTestCase extends DrupalWebTestCase {
+class HookBootExitTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -321,51 +322,51 @@ class HookBootExitTestCase extends DrupalWebTestCase {
 }
 
 /**
- * Test drupal_get_filename()'s availability.
+ * Test get_filename()'s availability.
  */
-class BootstrapGetFilenameTestCase extends DrupalUnitTestCase {
+class BootstrapGetFilenameTestCase extends UnitTestCase {
 
   public static function getInfo() {
     return array(
       'name' => 'Get filename test',
-      'description' => 'Test that drupal_get_filename() works correctly when the file is not found in the database.',
+      'description' => 'Test that get_filename() works correctly when the file is not found in the database.',
       'group' => 'Bootstrap',
     );
   }
 
   /**
-   * Test that drupal_get_filename() works correctly when the file is not found in the database.
+   * Test that get_filename() works correctly when the file is not found in the database.
    */
   function testDrupalGetFilename() {
     // Reset the static cache so we can test the "db is not active" code of
-    // drupal_get_filename().
-    drupal_static_reset('drupal_get_filename');
+    // get_filename().
+    drupal_static_reset('Drupal\get_filename');
 
     // Retrieving the location of a module.
-    $this->assertIdentical(drupal_get_filename('module', 'php'), 'core/modules/php/php.module', t('Retrieve module location.'));
+    $this->assertIdentical(get_filename('module', 'php'), 'core/modules/php/php.module', t('Retrieve module location.'));
 
     // Retrieving the location of a theme.
-    $this->assertIdentical(drupal_get_filename('theme', 'stark'), 'core/themes/stark/stark.info', t('Retrieve theme location.'));
+    $this->assertIdentical(get_filename('theme', 'stark'), 'core/themes/stark/stark.info', t('Retrieve theme location.'));
 
     // Retrieving the location of a theme engine.
-    $this->assertIdentical(drupal_get_filename('theme_engine', 'phptemplate'), 'core/themes/engines/phptemplate/phptemplate.engine', t('Retrieve theme engine location.'));
+    $this->assertIdentical(get_filename('theme_engine', 'phptemplate'), 'core/themes/engines/phptemplate/phptemplate.engine', t('Retrieve theme engine location.'));
 
     // Retrieving the location of a profile. Profiles are a special case with
     // a fixed location and naming.
-    $this->assertIdentical(drupal_get_filename('profile', 'standard'), 'profiles/standard/standard.profile', t('Retrieve install profile location.'));
+    $this->assertIdentical(get_filename('profile', 'standard'), 'profiles/standard/standard.profile', t('Retrieve install profile location.'));
 
-    // When a file is not found in the database cache, drupal_get_filename()
+    // When a file is not found in the database cache, get_filename()
     // searches several locations on the filesystem, including the core/
     // directory. We use the '.script' extension below because this is a
     // non-existent filetype that will definitely not exist in the database.
-    // Since there is already a core/scripts directory, drupal_get_filename()
+    // Since there is already a core/scripts directory, get_filename()
     // will automatically check there for 'script' files, just as it does
     // for (e.g.) 'module' files in core/modules.
-    $this->assertIdentical(drupal_get_filename('script', 'test'), 'core/scripts/test.script', t('Retrieve test script location.'));
+    $this->assertIdentical(get_filename('script', 'test'), 'core/scripts/test.script', t('Retrieve test script location.'));
   }
 }
 
-class BootstrapTimerTestCase extends DrupalUnitTestCase {
+class BootstrapTimerTestCase extends UnitTestCase {
 
   public static function getInfo() {
     return array(
@@ -400,7 +401,7 @@ class BootstrapTimerTestCase extends DrupalUnitTestCase {
 /**
  * Test that resetting static variables works.
  */
-class BootstrapResettableStaticTestCase extends DrupalUnitTestCase {
+class BootstrapResettableStaticTestCase extends UnitTestCase {
 
   public static function getInfo() {
     return array(
@@ -439,7 +440,7 @@ class BootstrapResettableStaticTestCase extends DrupalUnitTestCase {
 /**
  * Test miscellaneous functions in bootstrap.inc.
  */
-class BootstrapMiscTestCase extends DrupalUnitTestCase {
+class BootstrapMiscTestCase extends UnitTestCase {
 
   public static function getInfo() {
     return array(
@@ -453,28 +454,28 @@ class BootstrapMiscTestCase extends DrupalUnitTestCase {
    * Test miscellaneous functions in bootstrap.inc.
    */
   function testMisc() {
-    // Test drupal_array_merge_deep().
+    // Test array_merge_deep().
     $link_options_1 = array('fragment' => 'x', 'attributes' => array('title' => 'X', 'class' => array('a', 'b')), 'language' => 'en');
     $link_options_2 = array('fragment' => 'y', 'attributes' => array('title' => 'Y', 'class' => array('c', 'd')), 'html' => TRUE);
     $expected = array('fragment' => 'y', 'attributes' => array('title' => 'Y', 'class' => array('a', 'b', 'c', 'd')), 'language' => 'en', 'html' => TRUE);
-    $this->assertIdentical(drupal_array_merge_deep($link_options_1, $link_options_2), $expected, t('drupal_array_merge_deep() returned a properly merged array.'));
+    $this->assertIdentical(array_merge_deep($link_options_1, $link_options_2), $expected, t('array_merge_deep() returned a properly merged array.'));
   }
 }
 
 /**
  * Tests for overriding server variables via the API.
  */
-class BootstrapOverrideServerVariablesTestCase extends DrupalUnitTestCase {
+class BootstrapOverrideServerVariablesTestCase extends UnitTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Overriding server variables',
-      'description' => 'Test that drupal_override_server_variables() works correctly.',
+      'description' => 'Test that override_server_variables() works correctly.',
       'group' => 'Bootstrap',
     );
   }
 
   /**
-   * Test providing a direct URL to to drupal_override_server_variables().
+   * Test providing a direct URL to to override_server_variables().
    */
   function testDrupalOverrideServerVariablesProvidedURL() {
     $tests = array(
@@ -495,9 +496,9 @@ class BootstrapOverrideServerVariablesTestCase extends DrupalUnitTestCase {
       // Remember the original value of $_SERVER, since the function call below
       // will modify it.
       $original_server = $_SERVER;
-      // Call drupal_override_server_variables() and ensure that all expected
+      // Call override_server_variables() and ensure that all expected
       // $_SERVER variables were modified correctly.
-      drupal_override_server_variables(array('url' => $url));
+      override_server_variables(array('url' => $url));
       foreach ($expected_server_values as $key => $value) {
         $this->assertIdentical($_SERVER[$key], $value);
       }
diff --git a/core/modules/simpletest/tests/cache.test b/core/modules/simpletest/tests/cache.test
index bca4e25..4b75f44 100644
--- a/core/modules/simpletest/tests/cache.test
+++ b/core/modules/simpletest/tests/cache.test
@@ -1,6 +1,8 @@
 <?php
+namespace Drupal;
+use stdClass;
 
-class CacheTestCase extends DrupalWebTestCase {
+class CacheTestCase extends WebTestCase {
   protected $default_bin = 'page';
   protected $default_cid = 'test_temporary';
   protected $default_value = 'CacheTest';
@@ -315,7 +317,7 @@ class CacheClearCase extends CacheTestCase {
   }
 
   /**
-   * Test drupal_flush_all_caches().
+   * Test flush_all_caches().
    */
   function testFlushAllCaches() {
     // Create cache entries for each flushed cache bin.
@@ -327,7 +329,7 @@ class CacheClearCase extends CacheTestCase {
     }
 
     // Remove all caches then make sure that they are cleared.
-    drupal_flush_all_caches();
+    flush_all_caches();
 
     foreach ($bins as $id => $bin) {
       $cid = 'test_cid_clear' . $id;
diff --git a/core/modules/simpletest/tests/common.test b/core/modules/simpletest/tests/common.test
index ff80806..35e2984 100644
--- a/core/modules/simpletest/tests/common.test
+++ b/core/modules/simpletest/tests/common.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -8,11 +10,11 @@
 /**
  * Tests for URL generation functions.
  */
-class CommonDrupalAlterTestCase extends DrupalWebTestCase {
+class CommonDrupalAlterTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Alter hook functionality',
-      'description' => 'Tests alteration of arguments passed to drupal_alter().',
+      'description' => 'Tests alteration of arguments passed to alter().',
       'group' => 'Common',
     );
   }
@@ -35,13 +37,13 @@ class CommonDrupalAlterTestCase extends DrupalWebTestCase {
     // Verify alteration of a single argument.
     $array_copy = $array;
     $array_expected = array('foo' => 'Drupal theme');
-    drupal_alter('drupal_alter', $array_copy);
+    alter('alter', $array_copy);
     $this->assertEqual($array_copy, $array_expected, t('Single array was altered.'));
 
     $entity_copy = clone $entity;
     $entity_expected = clone $entity;
     $entity_expected->foo = 'Drupal theme';
-    drupal_alter('drupal_alter', $entity_copy);
+    alter('alter', $entity_copy);
     $this->assertEqual($entity_copy, $entity_expected, t('Single object was altered.'));
 
     // Verify alteration of multiple arguments.
@@ -52,17 +54,17 @@ class CommonDrupalAlterTestCase extends DrupalWebTestCase {
     $entity_expected->foo = 'Drupal theme';
     $array2_copy = $array;
     $array2_expected = array('foo' => 'Drupal theme');
-    drupal_alter('drupal_alter', $array_copy, $entity_copy, $array2_copy);
-    $this->assertEqual($array_copy, $array_expected, t('First argument to drupal_alter() was altered.'));
-    $this->assertEqual($entity_copy, $entity_expected, t('Second argument to drupal_alter() was altered.'));
-    $this->assertEqual($array2_copy, $array2_expected, t('Third argument to drupal_alter() was altered.'));
+    alter('alter', $array_copy, $entity_copy, $array2_copy);
+    $this->assertEqual($array_copy, $array_expected, t('First argument to alter() was altered.'));
+    $this->assertEqual($entity_copy, $entity_expected, t('Second argument to alter() was altered.'));
+    $this->assertEqual($array2_copy, $array2_expected, t('Third argument to alter() was altered.'));
 
-    // Verify alteration order when passing an array of types to drupal_alter().
+    // Verify alteration order when passing an array of types to alter().
     // common_test_module_implements_alter() places 'block' implementation after
     // other modules.
     $array_copy = $array;
     $array_expected = array('foo' => 'Drupal block theme');
-    drupal_alter(array('drupal_alter', 'drupal_alter_foo'), $array_copy);
+    alter(array('alter', 'alter_foo'), $array_copy);
     $this->assertEqual($array_copy, $array_expected, t('hook_TYPE_alter() implementations ran in correct order.'));
   }
 }
@@ -73,11 +75,11 @@ class CommonDrupalAlterTestCase extends DrupalWebTestCase {
  * url() calls module_implements(), which may issue a db query, which requires
  * inheriting from a web test case rather than a unit test case.
  */
-class CommonURLUnitTestCase extends DrupalWebTestCase {
+class URLUnitTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'URL generation tests',
-      'description' => 'Confirm that url(), drupal_get_query_parameters(), drupal_http_build_query(), and l() work correctly with various input.',
+      'description' => 'Confirm that url(), get_query_parameters(), drupal_http_build_query(), and l() work correctly with various input.',
       'group' => 'Common',
     );
   }
@@ -116,7 +118,7 @@ class CommonURLUnitTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Test drupal_get_query_parameters().
+   * Test get_query_parameters().
    */
   function testDrupalGetQueryParameters() {
     $original = array(
@@ -134,32 +136,32 @@ class CommonURLUnitTestCase extends DrupalWebTestCase {
     // Default arguments.
     $result = $_GET;
     unset($result['q']);
-    $this->assertEqual(drupal_get_query_parameters(), $result, t("\$_GET['q'] was removed."));
+    $this->assertEqual(get_query_parameters(), $result, t("\$_GET['q'] was removed."));
 
     // Default exclusion.
     $result = $original;
     unset($result['q']);
-    $this->assertEqual(drupal_get_query_parameters($original), $result, t("'q' was removed."));
+    $this->assertEqual(get_query_parameters($original), $result, t("'q' was removed."));
 
     // First-level exclusion.
     $result = $original;
     unset($result['b']);
-    $this->assertEqual(drupal_get_query_parameters($original, array('b')), $result, t("'b' was removed."));
+    $this->assertEqual(get_query_parameters($original, array('b')), $result, t("'b' was removed."));
 
     // Second-level exclusion.
     $result = $original;
     unset($result['b']['d']);
-    $this->assertEqual(drupal_get_query_parameters($original, array('b[d]')), $result, t("'b[d]' was removed."));
+    $this->assertEqual(get_query_parameters($original, array('b[d]')), $result, t("'b[d]' was removed."));
 
     // Third-level exclusion.
     $result = $original;
     unset($result['b']['e']['f']);
-    $this->assertEqual(drupal_get_query_parameters($original, array('b[e][f]')), $result, t("'b[e][f]' was removed."));
+    $this->assertEqual(get_query_parameters($original, array('b[e][f]')), $result, t("'b[e][f]' was removed."));
 
     // Multiple exclusions.
     $result = $original;
     unset($result['a'], $result['b']['e'], $result['c']);
-    $this->assertEqual(drupal_get_query_parameters($original, array('a', 'b[e]', 'c')), $result, t("'a', 'b[e]', 'c' were removed."));
+    $this->assertEqual(get_query_parameters($original, array('a', 'b[e]', 'c')), $result, t("'a', 'b[e]', 'c' were removed."));
   }
 
   /**
@@ -355,7 +357,7 @@ class CommonURLUnitTestCase extends DrupalWebTestCase {
 /**
  * Tests for the check_plain(), filter_xss() and format_string() functions.
  */
-class CommonXssUnitTestCase extends DrupalUnitTestCase {
+class CommonXssUnitTestCase extends UnitTestCase {
 
   public static function getInfo() {
     return array(
@@ -397,7 +399,7 @@ class CommonXssUnitTestCase extends DrupalUnitTestCase {
    * Test t() and format_string() replacement functionality.
    */
   function testFormatStringAndT() {
-    foreach (array('format_string', 't') as $function) {
+    foreach (array('Drupal\format_string', 'Drupal\t') as $function) {
       $text = $function('Simple text');
       $this->assertEqual($text, 'Simple text', $function . ' leaves simple text alone.');
       $text = $function('Escaped text: @value', array('@value' => '<script>'));
@@ -414,17 +416,17 @@ class CommonXssUnitTestCase extends DrupalUnitTestCase {
    */
   function testBadProtocolStripping() {
     // Ensure that check_url() strips out harmful protocols, and encodes for
-    // HTML. Ensure drupal_strip_dangerous_protocols() can be used to return a
+    // HTML. Ensure strip_dangerous_protocols() can be used to return a
     // plain-text string stripped of harmful protocols.
     $url = 'javascript:http://www.example.com/?x=1&y=2';
     $expected_plain = 'http://www.example.com/?x=1&y=2';
     $expected_html = 'http://www.example.com/?x=1&amp;y=2';
     $this->assertIdentical(check_url($url), $expected_html, t('check_url() filters a URL and encodes it for HTML.'));
-    $this->assertIdentical(drupal_strip_dangerous_protocols($url), $expected_plain, t('drupal_strip_dangerous_protocols() filters a URL and returns plain text.'));
+    $this->assertIdentical(strip_dangerous_protocols($url), $expected_plain, t('strip_dangerous_protocols() filters a URL and returns plain text.'));
   }
 }
 
-class CommonSizeUnitTestCase extends DrupalUnitTestCase {
+class CommonSizeUnitTestCase extends UnitTestCase {
   protected $exact_test_cases;
   protected $rounded_test_cases;
 
@@ -437,7 +439,7 @@ class CommonSizeUnitTestCase extends DrupalUnitTestCase {
   }
 
   function setUp() {
-    $kb = DRUPAL_KILOBYTE;
+    $kb = KILOBYTE;
     $this->exact_test_cases = array(
       '1 byte' => 1,
       '1 KB'   => $kb,
@@ -522,9 +524,9 @@ class CommonSizeUnitTestCase extends DrupalUnitTestCase {
 }
 
 /**
- * Test drupal_explode_tags() and drupal_implode_tags().
+ * Test explode_tags() and implode_tags().
  */
-class CommonAutocompleteTagsTestCase extends DrupalWebTestCase {
+class CommonAutocompleteTagsTestCase extends WebTestCase {
   var $validTags = array(
     'Drupal' => 'Drupal',
     'Drupal with some spaces' => 'Drupal with some spaces',
@@ -545,7 +547,7 @@ class CommonAutocompleteTagsTestCase extends DrupalWebTestCase {
    */
   function testDrupalExplodeTags() {
     $string = implode(', ', array_keys($this->validTags));
-    $tags = drupal_explode_tags($string);
+    $tags = explode_tags($string);
     $this->assertTags($tags);
   }
 
@@ -556,8 +558,8 @@ class CommonAutocompleteTagsTestCase extends DrupalWebTestCase {
     $tags = array_values($this->validTags);
     // Let's explode and implode to our heart's content.
     for ($i = 0; $i < 10; $i++) {
-      $string = drupal_implode_tags($tags);
-      $tags = drupal_explode_tags($string);
+      $string = implode_tags($tags);
+      $tags = explode_tags($string);
     }
     $this->assertTags($tags);
   }
@@ -581,7 +583,7 @@ class CommonAutocompleteTagsTestCase extends DrupalWebTestCase {
 /**
  * Test the Drupal CSS system.
  */
-class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
+class CommonCascadingStylesheetsTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Cascading stylesheets',
@@ -592,15 +594,15 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
 
   function setUp() {
     parent::setUp('php', 'language', 'common_test');
-    // Reset drupal_add_css() before each test.
-    drupal_static_reset('drupal_add_css');
+    // Reset add_css() before each test.
+    drupal_static_reset('Drupal\add_css');
   }
 
   /**
    * Check default stylesheets as empty.
    */
   function testDefault() {
-    $this->assertEqual(array(), drupal_add_css(), t('Default CSS is empty.'));
+    $this->assertEqual(array(), add_css(), t('Default CSS is empty.'));
   }
 
   /**
@@ -628,8 +630,8 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
    * Tests adding a file stylesheet.
    */
   function testAddFile() {
-    $path = drupal_get_path('module', 'simpletest') . '/simpletest.css';
-    $css = drupal_add_css($path);
+    $path = get_path('module', 'simpletest') . '/simpletest.css';
+    $css = add_css($path);
     $this->assertEqual($css[$path]['data'], $path, t('Adding a CSS file caches it properly.'));
   }
 
@@ -638,7 +640,7 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
    */
   function testAddExternal() {
     $path = 'http://example.com/style.css';
-    $css = drupal_add_css($path, 'external');
+    $css = add_css($path, 'external');
     $this->assertEqual($css[$path]['type'], 'external', t('Adding an external CSS file caches it properly.'));
   }
 
@@ -646,17 +648,17 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
    * Makes sure that reseting the CSS empties the cache.
    */
   function testReset() {
-    drupal_static_reset('drupal_add_css');
-    $this->assertEqual(array(), drupal_add_css(), t('Resetting the CSS empties the cache.'));
+    drupal_static_reset('Drupal\add_css');
+    $this->assertEqual(array(), add_css(), t('Resetting the CSS empties the cache.'));
   }
 
   /**
    * Tests rendering the stylesheets.
    */
   function testRenderFile() {
-    $css = drupal_get_path('module', 'simpletest') . '/simpletest.css';
-    drupal_add_css($css);
-    $styles = drupal_get_css();
+    $css = get_path('module', 'simpletest') . '/simpletest.css';
+    add_css($css);
+    $styles = get_css();
     $this->assertTrue(strpos($styles, $css) > 0, t('Rendered CSS includes the added stylesheet.'));
   }
 
@@ -665,8 +667,8 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
    */
   function testRenderExternal() {
     $css = 'http://example.com/style.css';
-    drupal_add_css($css, 'external');
-    $styles = drupal_get_css();
+    add_css($css, 'external');
+    $styles = get_css();
     // Stylesheet URL may be the href of a LINK tag or in an @import statement
     // of a STYLE tag.
     $this->assertTrue(strpos($styles, 'href="' . $css) > 0 || strpos($styles, '@import url("' . $css . '")') > 0, t('Rendering an external CSS file.'));
@@ -677,9 +679,9 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
    */
   function testRenderInlinePreprocess() {
     $css = 'body { padding: 0px; }';
-    $css_preprocessed = '<style media="all">' . "\n<!--/*--><![CDATA[/*><!--*/\n" . drupal_load_stylesheet_content($css, TRUE) . "\n/*]]>*/-->\n" . '</style>';
-    drupal_add_css($css, array('type' => 'inline'));
-    $styles = drupal_get_css();
+    $css_preprocessed = '<style media="all">' . "\n<!--/*--><![CDATA[/*><!--*/\n" . load_stylesheet_content($css, TRUE) . "\n/*]]>*/-->\n" . '</style>';
+    add_css($css, array('type' => 'inline'));
+    $styles = get_css();
     $this->assertEqual(trim($styles), $css_preprocessed, t('Rendering preprocessed inline CSS adds it to the page.'));
   }
 
@@ -688,8 +690,8 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
    */
   function testRenderInlineNoPreprocess() {
     $css = 'body { padding: 0px; }';
-    drupal_add_css($css, array('type' => 'inline', 'preprocess' => FALSE));
-    $styles = drupal_get_css();
+    add_css($css, array('type' => 'inline', 'preprocess' => FALSE));
+    $styles = get_css();
     $this->assertTrue(strpos($styles, $css) > 0, t('Rendering non-preprocessed inline CSS adds it to the page.'));
   }
 
@@ -699,17 +701,17 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
   function testRenderInlineFullPage() {
     $css = 'body { font-size: 254px; }';
     // Inline CSS is minified unless 'preprocess' => FALSE is passed as a
-    // drupal_add_css() option.
+    // add_css() option.
     $expected = 'body{font-size:254px;}';
 
-    // Create a node, using the PHP filter that tests drupal_add_css().
+    // Create a node, using the PHP filter that tests add_css().
     $php_format_id = 'php_code';
     $settings = array(
       'type' => 'page',
       'body' => array(
         LANGUAGE_NONE => array(
           array(
-            'value' => t('This tests the inline CSS!') . "<?php drupal_add_css('$css', 'inline'); ?>",
+            'value' => t('This tests the inline CSS!') . "<?php Drupal\add_css('$css', 'inline'); ?>",
             'format' => $php_format_id,
           ),
         ),
@@ -728,20 +730,20 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
    */
   function testRenderOrder() {
     // A module CSS file.
-    drupal_add_css(drupal_get_path('module', 'simpletest') . '/simpletest.css');
+    add_css(get_path('module', 'simpletest') . '/simpletest.css');
     // A few system CSS files, ordered in a strange way.
-    $system_path = drupal_get_path('module', 'system');
-    drupal_add_css($system_path . '/system.base.css', array('group' => CSS_SYSTEM, 'weight' => -10));
-    drupal_add_css($system_path . '/system.theme.css', array('group' => CSS_SYSTEM));
+    $system_path = get_path('module', 'system');
+    add_css($system_path . '/system.base.css', array('group' => CSS_SYSTEM, 'weight' => -10));
+    add_css($system_path . '/system.theme.css', array('group' => CSS_SYSTEM));
 
     $expected = array(
       $system_path . '/system.base.css',
       $system_path . '/system.theme.css',
-      drupal_get_path('module', 'simpletest') . '/simpletest.css',
+      get_path('module', 'simpletest') . '/simpletest.css',
     );
 
 
-    $styles = drupal_get_css();
+    $styles = get_css();
     // Stylesheet URL may be the href of a LINK tag or in an @import statement
     // of a STYLE tag.
     if (preg_match_all('/(href="|url\(")' . preg_quote($GLOBALS['base_url'] . '/', '/') . '([^?]+)\?/', $styles, $matches)) {
@@ -758,22 +760,22 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
    * Test CSS override.
    */
   function testRenderOverride() {
-    $system = drupal_get_path('module', 'system');
-    $simpletest = drupal_get_path('module', 'simpletest');
+    $system = get_path('module', 'system');
+    $simpletest = get_path('module', 'simpletest');
 
-    drupal_add_css($system . '/system.base.css');
-    drupal_add_css($simpletest . '/tests/system.base.css');
+    add_css($system . '/system.base.css');
+    add_css($simpletest . '/tests/system.base.css');
 
     // The dummy stylesheet should be the only one included.
-    $styles = drupal_get_css();
+    $styles = get_css();
     $this->assert(strpos($styles, $simpletest . '/tests/system.base.css') !== FALSE, t('The overriding CSS file is output.'));
     $this->assert(strpos($styles, $system . '/system.base.css') === FALSE, t('The overridden CSS file is not output.'));
 
-    drupal_add_css($simpletest . '/tests/system.base.css');
-    drupal_add_css($system . '/system.base.css');
+    add_css($simpletest . '/tests/system.base.css');
+    add_css($system . '/system.base.css');
 
     // The standard stylesheet should be the only one included.
-    $styles = drupal_get_css();
+    $styles = get_css();
     $this->assert(strpos($styles, $system . '/system.base.css') !== FALSE, t('The overriding CSS file is output.'));
     $this->assert(strpos($styles, $simpletest . '/tests/system.base.css') === FALSE, t('The overridden CSS file is not output.'));
   }
@@ -785,11 +787,11 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
     // Switch the language to a right to left language and add system.base.css.
     global $language;
     $language->direction = LANGUAGE_RTL;
-    $path = drupal_get_path('module', 'system');
-    drupal_add_css($path . '/system.base.css');
+    $path = get_path('module', 'system');
+    add_css($path . '/system.base.css');
 
     // Check to see if system.base-rtl.css was also added.
-    $styles = drupal_get_css();
+    $styles = get_css();
     $this->assert(strpos($styles, $path . '/system.base-rtl.css') !== FALSE, t('CSS is alterable as right to left overrides are added.'));
 
     // Change the language back to left to right.
@@ -803,75 +805,75 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
   function testAddCssFileWithQueryString() {
     $this->drupalGet('common-test/query-string');
     $query_string = variable_get('css_js_query_string', '0');
-    $this->assertRaw(drupal_get_path('module', 'node') . '/node.css?' . $query_string, t('Query string was appended correctly to css.'));
-    $this->assertRaw(drupal_get_path('module', 'node') . '/node-fake.css?arg1=value1&amp;arg2=value2', t('Query string not escaped on a URI.'));
+    $this->assertRaw(get_path('module', 'node') . '/node.css?' . $query_string, t('Query string was appended correctly to css.'));
+    $this->assertRaw(get_path('module', 'node') . '/node-fake.css?arg1=value1&amp;arg2=value2', t('Query string not escaped on a URI.'));
   }
 }
 
 /**
  * Test for cleaning HTML identifiers.
  */
-class CommonHTMLIdentifierTestCase extends DrupalUnitTestCase {
+class CommonHTMLIdentifierTestCase extends UnitTestCase {
   public static function getInfo() {
     return array(
       'name' => 'HTML identifiers',
-      'description' => 'Test the functions drupal_html_class(), drupal_html_id() and drupal_clean_css_identifier() for expected behavior',
+      'description' => 'Test the functions html_class(), html_id() and clean_css_identifier() for expected behavior',
       'group' => 'Common',
     );
   }
 
   /**
-   * Tests that drupal_clean_css_identifier() cleans the identifier properly.
+   * Tests that clean_css_identifier() cleans the identifier properly.
    */
   function testDrupalCleanCSSIdentifier() {
     // Verify that no valid ASCII characters are stripped from the identifier.
     $identifier = 'abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789';
-    $this->assertIdentical(drupal_clean_css_identifier($identifier, array()), $identifier, t('Verify valid ASCII characters pass through.'));
+    $this->assertIdentical(clean_css_identifier($identifier, array()), $identifier, t('Verify valid ASCII characters pass through.'));
 
     // Verify that valid UTF-8 characters are not stripped from the identifier.
     $identifier = '¡¢£¤¥';
-    $this->assertIdentical(drupal_clean_css_identifier($identifier, array()), $identifier, t('Verify valid UTF-8 characters pass through.'));
+    $this->assertIdentical(clean_css_identifier($identifier, array()), $identifier, t('Verify valid UTF-8 characters pass through.'));
 
     // Verify that invalid characters (including non-breaking space) are stripped from the identifier.
-    $this->assertIdentical(drupal_clean_css_identifier('invalid !"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ identifier', array()), 'invalididentifier', t('Strip invalid characters.'));
+    $this->assertIdentical(clean_css_identifier('invalid !"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ identifier', array()), 'invalididentifier', t('Strip invalid characters.'));
   }
 
   /**
-   * Tests that drupal_html_class() cleans the class name properly.
+   * Tests that html_class() cleans the class name properly.
    */
   function testDrupalHTMLClass() {
     // Verify Drupal coding standards are enforced.
-    $this->assertIdentical(drupal_html_class('CLASS NAME_[Ü]'), 'class-name--ü', t('Enforce Drupal coding standards.'));
+    $this->assertIdentical(html_class('CLASS NAME_[Ü]'), 'class-name--ü', t('Enforce Drupal coding standards.'));
   }
 
   /**
-   * Tests that drupal_html_id() cleans the ID properly.
+   * Tests that html_id() cleans the ID properly.
    */
   function testDrupalHTMLId() {
     // Verify that letters, digits, and hyphens are not stripped from the ID.
     $id = 'abcdefghijklmnopqrstuvwxyz-0123456789';
-    $this->assertIdentical(drupal_html_id($id), $id, t('Verify valid characters pass through.'));
+    $this->assertIdentical(html_id($id), $id, t('Verify valid characters pass through.'));
 
     // Verify that invalid characters are stripped from the ID.
-    $this->assertIdentical(drupal_html_id('invalid,./:@\\^`{Üidentifier'), 'invalididentifier', t('Strip invalid characters.'));
+    $this->assertIdentical(html_id('invalid,./:@\\^`{Üidentifier'), 'invalididentifier', t('Strip invalid characters.'));
 
     // Verify Drupal coding standards are enforced.
-    $this->assertIdentical(drupal_html_id('ID NAME_[1]'), 'id-name-1', t('Enforce Drupal coding standards.'));
+    $this->assertIdentical(html_id('ID NAME_[1]'), 'id-name-1', t('Enforce Drupal coding standards.'));
 
     // Reset the static cache so we can ensure the unique id count is at zero.
-    drupal_static_reset('drupal_html_id');
+    drupal_static_reset('Drupal\html_id');
 
     // Clean up IDs with invalid starting characters.
-    $this->assertIdentical(drupal_html_id('test-unique-id'), 'test-unique-id', t('Test the uniqueness of IDs #1.'));
-    $this->assertIdentical(drupal_html_id('test-unique-id'), 'test-unique-id--2', t('Test the uniqueness of IDs #2.'));
-    $this->assertIdentical(drupal_html_id('test-unique-id'), 'test-unique-id--3', t('Test the uniqueness of IDs #3.'));
+    $this->assertIdentical(html_id('test-unique-id'), 'test-unique-id', t('Test the uniqueness of IDs #1.'));
+    $this->assertIdentical(html_id('test-unique-id'), 'test-unique-id--2', t('Test the uniqueness of IDs #2.'));
+    $this->assertIdentical(html_id('test-unique-id'), 'test-unique-id--3', t('Test the uniqueness of IDs #3.'));
   }
 }
 
 /**
  * CSS Unit Tests.
  */
-class CommonCascadingStylesheetsUnitTestCase extends DrupalUnitTestCase {
+class CommonCascadingStylesheetsUnitTestCase extends UnitTestCase {
   public static function getInfo() {
     return array(
       'name' => 'CSS Unit Tests',
@@ -881,7 +883,7 @@ class CommonCascadingStylesheetsUnitTestCase extends DrupalUnitTestCase {
   }
 
   /**
-   * Tests basic CSS loading with and without optimization via drupal_load_stylesheet().
+   * Tests basic CSS loading with and without optimization via load_stylesheet().
    *
    * Known tests:
    * - Retain white-space in selectors. (http://drupal.org/node/472820)
@@ -898,32 +900,32 @@ class CommonCascadingStylesheetsUnitTestCase extends DrupalUnitTestCase {
       'css_input_with_import.css',
       'comment_hacks.css'
     );
-    $path = drupal_get_path('module', 'simpletest') . '/files/css_test_files';
+    $path = get_path('module', 'simpletest') . '/files/css_test_files';
     foreach ($testfiles as $file) {
       $expected = file_get_contents("$path/$file.unoptimized.css");
-      $unoptimized_output = drupal_load_stylesheet("$path/$file.unoptimized.css", FALSE);
+      $unoptimized_output = load_stylesheet("$path/$file.unoptimized.css", FALSE);
       $this->assertEqual($unoptimized_output, $expected, t('Unoptimized CSS file has expected contents (@file)', array('@file' => $file)));
 
       $expected = file_get_contents("$path/$file.optimized.css");
-      $optimized_output = drupal_load_stylesheet("$path/$file", TRUE);
+      $optimized_output = load_stylesheet("$path/$file", TRUE);
       $this->assertEqual($optimized_output, $expected, t('Optimized CSS file has expected contents (@file)', array('@file' => $file)));
 
       // Repeat the tests by accessing the stylesheets by URL.
       $expected = file_get_contents("$path/$file.unoptimized.css");
-      $unoptimized_output_url = drupal_load_stylesheet($GLOBALS['base_url'] . "/$path/$file.unoptimized.css", FALSE);
+      $unoptimized_output_url = load_stylesheet($GLOBALS['base_url'] . "/$path/$file.unoptimized.css", FALSE);
       $this->assertEqual($unoptimized_output, $expected, t('Unoptimized CSS file (loaded from an URL) has expected contents (@file)', array('@file' => $file)));
 
       $expected = file_get_contents("$path/$file.optimized.css");
-      $optimized_output = drupal_load_stylesheet($GLOBALS['base_url'] . "/$path/$file", TRUE);
+      $optimized_output = load_stylesheet($GLOBALS['base_url'] . "/$path/$file", TRUE);
       $this->assertEqual($optimized_output, $expected, t('Optimized CSS file (loaded from an URL) has expected contents (@file)', array('@file' => $file)));
     }
   }
 }
 
 /**
- * Test drupal_http_request().
+ * Test http_request().
  */
-class CommonDrupalHTTPRequestTestCase extends DrupalWebTestCase {
+class CommonDrupalHTTPRequestTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Drupal HTTP request',
@@ -940,22 +942,22 @@ class CommonDrupalHTTPRequestTestCase extends DrupalWebTestCase {
     global $is_https;
 
     // Parse URL schema.
-    $missing_scheme = drupal_http_request('example.com/path');
+    $missing_scheme = http_request('example.com/path');
     $this->assertEqual($missing_scheme->code, -1002, t('Returned with "-1002" error code.'));
     $this->assertEqual($missing_scheme->error, 'missing schema', t('Returned with "missing schema" error message.'));
 
-    $unable_to_parse = drupal_http_request('http:///path');
+    $unable_to_parse = http_request('http:///path');
     $this->assertEqual($unable_to_parse->code, -1001, t('Returned with "-1001" error code.'));
     $this->assertEqual($unable_to_parse->error, 'unable to parse URL', t('Returned with "unable to parse URL" error message.'));
 
     // Fetch page.
-    $result = drupal_http_request(url('node', array('absolute' => TRUE)));
+    $result = http_request(url('node', array('absolute' => TRUE)));
     $this->assertEqual($result->code, 200, t('Fetched page successfully.'));
     $this->drupalSetContent($result->data);
     $this->assertTitle(t('Welcome to @site-name | @site-name', array('@site-name' => variable_get('site_name', 'Drupal'))), t('Site title matches.'));
 
     // Test that code and status message is returned.
-    $result = drupal_http_request(url('pagedoesnotexist', array('absolute' => TRUE)));
+    $result = http_request(url('pagedoesnotexist', array('absolute' => TRUE)));
     $this->assertTrue(!empty($result->protocol),  t('Result protocol is returned.'));
     $this->assertEqual($result->code, '404', t('Result code is 404'));
     $this->assertEqual($result->status_message, 'Not Found', t('Result status message is "Not Found"'));
@@ -971,7 +973,7 @@ class CommonDrupalHTTPRequestTestCase extends DrupalWebTestCase {
       // slightly less than the specified timeout, so allow a little slack on
       // the minimum expected time (i.e. 1.8 instead of 2).
       timer_start(__METHOD__);
-      $result = drupal_http_request(url('system-test/sleep/10', array('absolute' => TRUE)), array('timeout' => 2));
+      $result = http_request(url('system-test/sleep/10', array('absolute' => TRUE)), array('timeout' => 2));
       $time = timer_read(__METHOD__) / 1000;
       $this->assertTrue(1.8 < $time && $time < 5, t('Request timed out (%time seconds).', array('%time' => $time)));
       $this->assertTrue($result->error, t('An error message was returned.'));
@@ -985,7 +987,7 @@ class CommonDrupalHTTPRequestTestCase extends DrupalWebTestCase {
     $url = url('system-test/auth', array('absolute' => TRUE));
 
     $auth = str_replace('://', '://' . $username . ':' . $password . '@', $url);
-    $result = drupal_http_request($auth);
+    $result = http_request($auth);
 
     $this->drupalSetContent($result->data);
     $this->assertRaw($username, t('$_SERVER["PHP_AUTH_USER"] is passed correctly.'));
@@ -993,49 +995,49 @@ class CommonDrupalHTTPRequestTestCase extends DrupalWebTestCase {
   }
 
   function testDrupalHTTPRequestRedirect() {
-    $redirect_301 = drupal_http_request(url('system-test/redirect/301', array('absolute' => TRUE)), array('max_redirects' => 1));
-    $this->assertEqual($redirect_301->redirect_code, 301, t('drupal_http_request follows the 301 redirect.'));
+    $redirect_301 = http_request(url('system-test/redirect/301', array('absolute' => TRUE)), array('max_redirects' => 1));
+    $this->assertEqual($redirect_301->redirect_code, 301, t('http_request follows the 301 redirect.'));
 
-    $redirect_301 = drupal_http_request(url('system-test/redirect/301', array('absolute' => TRUE)), array('max_redirects' => 0));
-    $this->assertFalse(isset($redirect_301->redirect_code), t('drupal_http_request does not follow 301 redirect if max_redirects = 0.'));
+    $redirect_301 = http_request(url('system-test/redirect/301', array('absolute' => TRUE)), array('max_redirects' => 0));
+    $this->assertFalse(isset($redirect_301->redirect_code), t('http_request does not follow 301 redirect if max_redirects = 0.'));
 
-    $redirect_invalid = drupal_http_request(url('system-test/redirect-noscheme', array('absolute' => TRUE)), array('max_redirects' => 1));
+    $redirect_invalid = http_request(url('system-test/redirect-noscheme', array('absolute' => TRUE)), array('max_redirects' => 1));
     $this->assertEqual($redirect_invalid->code, -1002, t('301 redirect to invalid URL returned with error code !error.', array('!error' => $redirect_invalid->error)));
     $this->assertEqual($redirect_invalid->error, 'missing schema', t('301 redirect to invalid URL returned with error message "!error".', array('!error' => $redirect_invalid->error)));
 
-    $redirect_invalid = drupal_http_request(url('system-test/redirect-noparse', array('absolute' => TRUE)), array('max_redirects' => 1));
+    $redirect_invalid = http_request(url('system-test/redirect-noparse', array('absolute' => TRUE)), array('max_redirects' => 1));
     $this->assertEqual($redirect_invalid->code, -1001, t('301 redirect to invalid URL returned with error message code "!error".', array('!error' => $redirect_invalid->error)));
     $this->assertEqual($redirect_invalid->error, 'unable to parse URL', t('301 redirect to invalid URL returned with error message "!error".', array('!error' => $redirect_invalid->error)));
 
-    $redirect_invalid = drupal_http_request(url('system-test/redirect-invalid-scheme', array('absolute' => TRUE)), array('max_redirects' => 1));
+    $redirect_invalid = http_request(url('system-test/redirect-invalid-scheme', array('absolute' => TRUE)), array('max_redirects' => 1));
     $this->assertEqual($redirect_invalid->code, -1003, t('301 redirect to invalid URL returned with error code !error.', array('!error' => $redirect_invalid->error)));
     $this->assertEqual($redirect_invalid->error, 'invalid schema ftp', t('301 redirect to invalid URL returned with error message "!error".', array('!error' => $redirect_invalid->error)));
 
-    $redirect_302 = drupal_http_request(url('system-test/redirect/302', array('absolute' => TRUE)), array('max_redirects' => 1));
-    $this->assertEqual($redirect_302->redirect_code, 302, t('drupal_http_request follows the 302 redirect.'));
+    $redirect_302 = http_request(url('system-test/redirect/302', array('absolute' => TRUE)), array('max_redirects' => 1));
+    $this->assertEqual($redirect_302->redirect_code, 302, t('http_request follows the 302 redirect.'));
 
-    $redirect_302 = drupal_http_request(url('system-test/redirect/302', array('absolute' => TRUE)), array('max_redirects' => 0));
-    $this->assertFalse(isset($redirect_302->redirect_code), t('drupal_http_request does not follow 302 redirect if $retry = 0.'));
+    $redirect_302 = http_request(url('system-test/redirect/302', array('absolute' => TRUE)), array('max_redirects' => 0));
+    $this->assertFalse(isset($redirect_302->redirect_code), t('http_request does not follow 302 redirect if $retry = 0.'));
 
-    $redirect_307 = drupal_http_request(url('system-test/redirect/307', array('absolute' => TRUE)), array('max_redirects' => 1));
-    $this->assertEqual($redirect_307->redirect_code, 307, t('drupal_http_request follows the 307 redirect.'));
+    $redirect_307 = http_request(url('system-test/redirect/307', array('absolute' => TRUE)), array('max_redirects' => 1));
+    $this->assertEqual($redirect_307->redirect_code, 307, t('http_request follows the 307 redirect.'));
 
-    $redirect_307 = drupal_http_request(url('system-test/redirect/307', array('absolute' => TRUE)), array('max_redirects' => 0));
-    $this->assertFalse(isset($redirect_307->redirect_code), t('drupal_http_request does not follow 307 redirect if max_redirects = 0.'));
+    $redirect_307 = http_request(url('system-test/redirect/307', array('absolute' => TRUE)), array('max_redirects' => 0));
+    $this->assertFalse(isset($redirect_307->redirect_code), t('http_request does not follow 307 redirect if max_redirects = 0.'));
 
     $multiple_redirect_final_url = url('system-test/multiple-redirects/0', array('absolute' => TRUE));
-    $multiple_redirect_1 = drupal_http_request(url('system-test/multiple-redirects/1', array('absolute' => TRUE)), array('max_redirects' => 1));
+    $multiple_redirect_1 = http_request(url('system-test/multiple-redirects/1', array('absolute' => TRUE)), array('max_redirects' => 1));
     $this->assertEqual($multiple_redirect_1->redirect_url, $multiple_redirect_final_url, t('redirect_url contains the final redirection location after 1 redirect.'));
 
-    $multiple_redirect_3 = drupal_http_request(url('system-test/multiple-redirects/3', array('absolute' => TRUE)), array('max_redirects' => 3));
+    $multiple_redirect_3 = http_request(url('system-test/multiple-redirects/3', array('absolute' => TRUE)), array('max_redirects' => 3));
     $this->assertEqual($multiple_redirect_3->redirect_url, $multiple_redirect_final_url, t('redirect_url contains the final redirection location after 3 redirects.'));
   }
 }
 
 /**
- * Tests drupal_add_region_content() and drupal_get_region_content().
+ * Tests add_region_content() and get_region_content().
  */
-class CommonRegionContentTestCase extends DrupalWebTestCase {
+class CommonRegionContentTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Region content',
@@ -1056,35 +1058,35 @@ class CommonRegionContentTestCase extends DrupalWebTestCase {
     // Set some random content for each region available.
     foreach ($block_regions as $region) {
       $first_chunk = $this->randomName(32);
-      drupal_add_region_content($region, $first_chunk);
+      add_region_content($region, $first_chunk);
       $second_chunk = $this->randomName(32);
-      drupal_add_region_content($region, $second_chunk);
-      // Store the expected result for a drupal_get_region_content call for this region.
+      add_region_content($region, $second_chunk);
+      // Store the expected result for a get_region_content call for this region.
       $values[$region] = $first_chunk . $delimiter . $second_chunk;
     }
 
-    // Ensure drupal_get_region_content returns expected results when fetching all regions.
-    $content = drupal_get_region_content(NULL, $delimiter);
+    // Ensure get_region_content returns expected results when fetching all regions.
+    $content = get_region_content(NULL, $delimiter);
     foreach ($content as $region => $region_content) {
       $this->assertEqual($region_content, $values[$region], t('@region region text verified when fetching all regions', array('@region' => $region)));
     }
 
-    // Ensure drupal_get_region_content returns expected results when fetching a single region.
+    // Ensure get_region_content returns expected results when fetching a single region.
     foreach ($block_regions as $region) {
-      $region_content = drupal_get_region_content($region, $delimiter);
+      $region_content = get_region_content($region, $delimiter);
       $this->assertEqual($region_content, $values[$region], t('@region region text verified when fetching single region.', array('@region' => $region)));
     }
   }
 }
 
 /**
- * Tests drupal_goto() and hook_drupal_goto_alter().
+ * Tests redirect() and hook_redirect_alter().
  */
-class CommonDrupalGotoTestCase extends DrupalWebTestCase {
+class CommonDrupalRedirectTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Redirect functionality',
-      'description' => 'Tests the drupal_goto() and hook_drupal_goto_alter() functionality.',
+      'description' => 'Tests the redirect() and hook_redirect_alter() functionality.',
       'group' => 'Common',
     );
   }
@@ -1094,43 +1096,43 @@ class CommonDrupalGotoTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Test drupal_goto().
+   * Test redirect().
    */
-  function testDrupalGoto() {
-    $this->drupalGet('common-test/drupal_goto/redirect');
+  function testRedirect() {
+    $this->drupalGet('common-test/redirect/redirect');
     $headers = $this->drupalGetHeaders(TRUE);
     list(, $status) = explode(' ', $headers[0][':status'], 3);
     $this->assertEqual($status, 302, t('Expected response code was sent.'));
-    $this->assertText('drupal_goto', t('Drupal goto redirect succeeded.'));
-    $this->assertEqual($this->getUrl(), url('common-test/drupal_goto', array('absolute' => TRUE)), t('Drupal goto redirected to expected URL.'));
+    $this->assertText('redirect', t('Drupal redirect redirect succeeded.'));
+    $this->assertEqual($this->getUrl(), url('common-test/redirect', array('absolute' => TRUE)), t('Drupal redirect redirected to expected URL.'));
 
-    $this->drupalGet('common-test/drupal_goto/redirect_advanced');
+    $this->drupalGet('common-test/redirect/redirect_advanced');
     $headers = $this->drupalGetHeaders(TRUE);
     list(, $status) = explode(' ', $headers[0][':status'], 3);
     $this->assertEqual($status, 301, t('Expected response code was sent.'));
-    $this->assertText('drupal_goto', t('Drupal goto redirect succeeded.'));
-    $this->assertEqual($this->getUrl(), url('common-test/drupal_goto', array('query' => array('foo' => '123'), 'absolute' => TRUE)), t('Drupal goto redirected to expected URL.'));
+    $this->assertText('redirect', t('Drupal redirect redirect succeeded.'));
+    $this->assertEqual($this->getUrl(), url('common-test/redirect', array('query' => array('foo' => '123'), 'absolute' => TRUE)), t('Drupal redirect redirected to expected URL.'));
 
-    // Test that drupal_goto() respects ?destination=xxx. Use an complicated URL
+    // Test that redirect() respects ?destination=xxx. Use an complicated URL
     // to test that the path is encoded and decoded properly.
-    $destination = 'common-test/drupal_goto/destination?foo=%2525&bar=123';
-    $this->drupalGet('common-test/drupal_goto/redirect', array('query' => array('destination' => $destination)));
-    $this->assertText('drupal_goto', t('Drupal goto redirect with destination succeeded.'));
-    $this->assertEqual($this->getUrl(), url('common-test/drupal_goto/destination', array('query' => array('foo' => '%25', 'bar' => '123'), 'absolute' => TRUE)), t('Drupal goto redirected to given query string destination.'));
+    $destination = 'common-test/redirect/destination?foo=%2525&bar=123';
+    $this->drupalGet('common-test/redirect/redirect', array('query' => array('destination' => $destination)));
+    $this->assertText('redirect', t('Drupal redirect redirect with destination succeeded.'));
+    $this->assertEqual($this->getUrl(), url('common-test/redirect/destination', array('query' => array('foo' => '%25', 'bar' => '123'), 'absolute' => TRUE)), t('Drupal redirect redirected to given query string destination.'));
   }
 
   /**
-   * Test hook_drupal_goto_alter().
+   * Test hook_redirect_alter().
    */
-  function testDrupalGotoAlter() {
-    $this->drupalGet('common-test/drupal_goto/redirect_fail');
+  function testDrupalRedirectAlter() {
+    $this->drupalGet('common-test/redirect/redirect_fail');
 
-    $this->assertNoText(t("Drupal goto failed to stop program"), t("Drupal goto stopped program."));
-    $this->assertNoText('drupal_goto_fail', t("Drupal goto redirect failed."));
+    $this->assertNoText(t("Drupal redirect failed to stop program"), t("Drupal redirect stopped program."));
+    $this->assertNoText('redirect_fail', t("Drupal redirect redirect failed."));
   }
 
   /**
-   * Test drupal_get_destination().
+   * Test get_destination().
    */
   function testDrupalGetDestination() {
     $query = $this->randomName(10);
@@ -1149,7 +1151,7 @@ class CommonDrupalGotoTestCase extends DrupalWebTestCase {
 /**
  * Tests for the JavaScript system.
  */
-class CommonJavaScriptTestCase extends DrupalWebTestCase {
+class CommonJavaScriptTestCase extends WebTestCase {
   /**
    * Store configured value for JavaScript preprocessing.
    */
@@ -1171,9 +1173,9 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
     $this->preprocess_js = variable_get('preprocess_js', 0);
     variable_set('preprocess_js', 0);
 
-    // Reset drupal_add_js() and drupal_add_library() statics before each test.
-    drupal_static_reset('drupal_add_js');
-    drupal_static_reset('drupal_add_library');
+    // Reset add_js() and add_library() statics before each test.
+    drupal_static_reset('Drupal\add_js');
+    drupal_static_reset('Drupal\add_library');
   }
 
   function tearDown() {
@@ -1186,14 +1188,14 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    * Test default JavaScript is empty.
    */
   function testDefault() {
-    $this->assertEqual(array(), drupal_add_js(), t('Default JavaScript is empty.'));
+    $this->assertEqual(array(), add_js(), t('Default JavaScript is empty.'));
   }
 
   /**
    * Test adding a JavaScript file.
    */
   function testAddFile() {
-    $javascript = drupal_add_js('core/misc/collapse.js');
+    $javascript = add_js('core/misc/collapse.js');
     $this->assertTrue(array_key_exists('core/misc/jquery.js', $javascript), t('jQuery is added when a file is added.'));
     $this->assertTrue(array_key_exists('core/misc/drupal.js', $javascript), t('Drupal.js is added when file is added.'));
     $this->assertTrue(array_key_exists('core/misc/html5.js', $javascript), t('html5.js is added when file is added.'));
@@ -1207,7 +1209,7 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    * Test adding settings.
    */
   function testAddSetting() {
-    $javascript = drupal_add_js(array('drupal' => 'rocks', 'dries' => 280342800), 'setting');
+    $javascript = add_js(array('drupal' => 'rocks', 'dries' => 280342800), 'setting');
     $this->assertEqual(280342800, $javascript['settings']['data'][2]['dries'], t('JavaScript setting is set correctly.'));
     $this->assertEqual('rocks', $javascript['settings']['data'][2]['drupal'], t('The other JavaScript setting is set correctly.'));
   }
@@ -1217,52 +1219,52 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    */
   function testAddExternal() {
     $path = 'http://example.com/script.js';
-    $javascript = drupal_add_js($path, 'external');
+    $javascript = add_js($path, 'external');
     $this->assertTrue(array_key_exists('http://example.com/script.js', $javascript), t('Added an external JavaScript file.'));
   }
 
   /**
-   * Test drupal_get_js() for JavaScript settings.
+   * Test get_js() for JavaScript settings.
    */
   function testHeaderSetting() {
     // Only the second of these two entries should appear in Drupal.settings.
-    drupal_add_js(array('commonTest' => 'commonTestShouldNotAppear'), 'setting');
-    drupal_add_js(array('commonTest' => 'commonTestShouldAppear'), 'setting');
+    add_js(array('commonTest' => 'commonTestShouldNotAppear'), 'setting');
+    add_js(array('commonTest' => 'commonTestShouldAppear'), 'setting');
     // All three of these entries should appear in Drupal.settings.
-    drupal_add_js(array('commonTestArray' => array('commonTestValue0')), 'setting');
-    drupal_add_js(array('commonTestArray' => array('commonTestValue1')), 'setting');
-    drupal_add_js(array('commonTestArray' => array('commonTestValue2')), 'setting');
+    add_js(array('commonTestArray' => array('commonTestValue0')), 'setting');
+    add_js(array('commonTestArray' => array('commonTestValue1')), 'setting');
+    add_js(array('commonTestArray' => array('commonTestValue2')), 'setting');
     // Only the second of these two entries should appear in Drupal.settings.
-    drupal_add_js(array('commonTestArray' => array('key' => 'commonTestOldValue')), 'setting');
-    drupal_add_js(array('commonTestArray' => array('key' => 'commonTestNewValue')), 'setting');
+    add_js(array('commonTestArray' => array('key' => 'commonTestOldValue')), 'setting');
+    add_js(array('commonTestArray' => array('key' => 'commonTestNewValue')), 'setting');
 
-    $javascript = drupal_get_js('header');
+    $javascript = get_js('header');
     $this->assertTrue(strpos($javascript, 'basePath') > 0, t('Rendered JavaScript header returns basePath setting.'));
     $this->assertTrue(strpos($javascript, 'core/misc/jquery.js') > 0, t('Rendered JavaScript header includes jQuery.'));
     $this->assertTrue(strpos($javascript, 'pathPrefix') > 0, t('Rendered JavaScript header returns pathPrefix setting.'));
 
-    // Test whether drupal_add_js can be used to override a previous setting.
+    // Test whether add_js can be used to override a previous setting.
     $this->assertTrue(strpos($javascript, 'commonTestShouldAppear') > 0, t('Rendered JavaScript header returns custom setting.'));
-    $this->assertTrue(strpos($javascript, 'commonTestShouldNotAppear') === FALSE, t('drupal_add_js() correctly overrides a custom setting.'));
+    $this->assertTrue(strpos($javascript, 'commonTestShouldNotAppear') === FALSE, t('add_js() correctly overrides a custom setting.'));
 
-    // Test whether drupal_add_js can be used to add numerically indexed values
+    // Test whether add_js can be used to add numerically indexed values
     // to an array.
     $array_values_appear = strpos($javascript, 'commonTestValue0') > 0 && strpos($javascript, 'commonTestValue1') > 0 && strpos($javascript, 'commonTestValue2') > 0;
-    $this->assertTrue($array_values_appear, t('drupal_add_js() correctly adds settings to the end of an indexed array.'));
+    $this->assertTrue($array_values_appear, t('add_js() correctly adds settings to the end of an indexed array.'));
 
-    // Test whether drupal_add_js can be used to override the entry for an
+    // Test whether add_js can be used to override the entry for an
     // existing key in an associative array.
     $associative_array_override = strpos($javascript, 'commonTestNewValue') > 0 && strpos($javascript, 'commonTestOldValue') === FALSE;
-    $this->assertTrue($associative_array_override, t('drupal_add_js() correctly overrides settings within an associative array.'));
+    $this->assertTrue($associative_array_override, t('add_js() correctly overrides settings within an associative array.'));
   }
 
   /**
    * Test to see if resetting the JavaScript empties the cache.
    */
   function testReset() {
-    drupal_add_js('core/misc/collapse.js');
-    drupal_static_reset('drupal_add_js');
-    $this->assertEqual(array(), drupal_add_js(), t('Resetting the JavaScript correctly empties the cache.'));
+    add_js('core/misc/collapse.js');
+    drupal_static_reset('Drupal\add_js');
+    $this->assertEqual(array(), add_js(), t('Resetting the JavaScript correctly empties the cache.'));
   }
 
   /**
@@ -1270,7 +1272,7 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    */
   function testAddInline() {
     $inline = 'jQuery(function () { });';
-    $javascript = drupal_add_js($inline, array('type' => 'inline', 'scope' => 'footer'));
+    $javascript = add_js($inline, array('type' => 'inline', 'scope' => 'footer'));
     $this->assertTrue(array_key_exists('core/misc/jquery.js', $javascript), t('jQuery is added when inline scripts are added.'));
     $data = end($javascript);
     $this->assertEqual($inline, $data['data'], t('Inline JavaScript is correctly added to the footer.'));
@@ -1281,27 +1283,27 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    */
   function testRenderExternal() {
     $external = 'http://example.com/example.js';
-    drupal_add_js($external, 'external');
-    $javascript = drupal_get_js();
+    add_js($external, 'external');
+    $javascript = get_js();
     // Local files have a base_path() prefix, external files should not.
     $this->assertTrue(strpos($javascript, 'src="' . $external) > 0, t('Rendering an external JavaScript file.'));
   }
 
   /**
-   * Test drupal_get_js() with a footer scope.
+   * Test get_js() with a footer scope.
    */
   function testFooterHTML() {
     $inline = 'jQuery(function () { });';
-    drupal_add_js($inline, array('type' => 'inline', 'scope' => 'footer'));
-    $javascript = drupal_get_js('footer');
+    add_js($inline, array('type' => 'inline', 'scope' => 'footer'));
+    $javascript = get_js('footer');
     $this->assertTrue(strpos($javascript, $inline) > 0, t('Rendered JavaScript footer returns the inline code.'));
   }
 
   /**
-   * Test drupal_add_js() sets preproccess to false when cache is set to false.
+   * Test add_js() sets preproccess to false when cache is set to false.
    */
   function testNoCache() {
-    $javascript = drupal_add_js('core/misc/collapse.js', array('cache' => FALSE));
+    $javascript = add_js('core/misc/collapse.js', array('cache' => FALSE));
     $this->assertFalse($javascript['core/misc/collapse.js']['preprocess'], t('Setting cache to FALSE sets proprocess to FALSE when adding JavaScript.'));
   }
 
@@ -1309,7 +1311,7 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    * Test adding a JavaScript file with a different group.
    */
   function testDifferentGroup() {
-    $javascript = drupal_add_js('core/misc/collapse.js', array('group' => JS_THEME));
+    $javascript = add_js('core/misc/collapse.js', array('group' => JS_THEME));
     $this->assertEqual($javascript['core/misc/collapse.js']['group'], JS_THEME, t('Adding a JavaScript file with a different group caches the given group.'));
   }
 
@@ -1317,21 +1319,21 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    * Test adding a JavaScript file with a different weight.
    */
   function testDifferentWeight() {
-    $javascript = drupal_add_js('core/misc/collapse.js', array('weight' => 2));
+    $javascript = add_js('core/misc/collapse.js', array('weight' => 2));
     $this->assertEqual($javascript['core/misc/collapse.js']['weight'], 2, t('Adding a JavaScript file with a different weight caches the given weight.'));
   }
 
   /**
    * Test adding JavaScript within conditional comments.
    *
-   * @see drupal_pre_render_conditional_comments()
+   * @see pre_render_conditional_comments()
    */
   function testBrowserConditionalComments() {
     $default_query_string = variable_get('css_js_query_string', '0');
 
-    drupal_add_js('core/misc/collapse.js', array('browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE)));
-    drupal_add_js('jQuery(function () { });', array('type' => 'inline', 'browsers' => array('IE' => FALSE)));
-    $javascript = drupal_get_js();
+    add_js('core/misc/collapse.js', array('browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE)));
+    add_js('jQuery(function () { });', array('type' => 'inline', 'browsers' => array('IE' => FALSE)));
+    $javascript = get_js();
 
     $expected_1 = "<!--[if lte IE 8]>\n" . '<script type="text/javascript" src="' . file_create_url('core/misc/collapse.js') . '?' . $default_query_string . '"></script>' . "\n<![endif]-->";
     $expected_2 = "<!--[if !IE]><!-->\n" . '<script type="text/javascript">' . "\n<!--//--><![CDATA[//><!--\n" . 'jQuery(function () { });' . "\n//--><!]]>\n" . '</script>' . "\n<!--<![endif]-->";
@@ -1344,9 +1346,9 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    * Test JavaScript versioning.
    */
   function testVersionQueryString() {
-    drupal_add_js('core/misc/collapse.js', array('version' => 'foo'));
-    drupal_add_js('core/misc/ajax.js', array('version' => 'bar'));
-    $javascript = drupal_get_js();
+    add_js('core/misc/collapse.js', array('version' => 'foo'));
+    add_js('core/misc/ajax.js', array('version' => 'bar'));
+    $javascript = get_js();
     $this->assertTrue(strpos($javascript, 'core/misc/collapse.js?v=foo') > 0 && strpos($javascript, 'core/misc/ajax.js?v=bar') > 0 , t('JavaScript version identifiers correctly appended to URLs'));
   }
 
@@ -1360,11 +1362,11 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
     // ahead of ones without. The order of JavaScript execution must be the
     // same regardless of whether aggregation is enabled, so ensure this
     // expected order, first with aggregation off.
-    drupal_add_js('core/misc/ajax.js');
-    drupal_add_js('core/misc/authorize.js', array('every_page' => TRUE));
-    drupal_add_js('core/misc/autocomplete.js');
-    drupal_add_js('core/misc/batch.js', array('every_page' => TRUE));
-    $javascript = drupal_get_js();
+    add_js('core/misc/ajax.js');
+    add_js('core/misc/authorize.js', array('every_page' => TRUE));
+    add_js('core/misc/autocomplete.js');
+    add_js('core/misc/batch.js', array('every_page' => TRUE));
+    $javascript = get_js();
     $expected = implode("\n", array(
       '<script type="text/javascript" src="' . file_create_url('core/misc/authorize.js') . '?' . $default_query_string . '"></script>',
       '<script type="text/javascript" src="' . file_create_url('core/misc/batch.js') . '?' . $default_query_string . '"></script>',
@@ -1375,17 +1377,17 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
 
     // Now ensure that with aggregation on, one file is made for the
     // 'every_page' files, and one file is made for the others.
-    drupal_static_reset('drupal_add_js');
+    drupal_static_reset('Drupal\add_js');
     variable_set('preprocess_js', 1);
-    drupal_add_js('core/misc/ajax.js');
-    drupal_add_js('core/misc/authorize.js', array('every_page' => TRUE));
-    drupal_add_js('core/misc/autocomplete.js');
-    drupal_add_js('core/misc/batch.js', array('every_page' => TRUE));
-    $js_items = drupal_add_js();
-    $javascript = drupal_get_js();
+    add_js('core/misc/ajax.js');
+    add_js('core/misc/authorize.js', array('every_page' => TRUE));
+    add_js('core/misc/autocomplete.js');
+    add_js('core/misc/batch.js', array('every_page' => TRUE));
+    $js_items = add_js();
+    $javascript = get_js();
     $expected = implode("\n", array(
-      '<script type="text/javascript" src="' . file_create_url(drupal_build_js_cache(array('core/misc/authorize.js' => $js_items['core/misc/authorize.js'], 'core/misc/batch.js' => $js_items['core/misc/batch.js']))) . '"></script>',
-      '<script type="text/javascript" src="' . file_create_url(drupal_build_js_cache(array('core/misc/ajax.js' => $js_items['core/misc/ajax.js'], 'core/misc/autocomplete.js' => $js_items['core/misc/autocomplete.js']))) . '"></script>',
+      '<script type="text/javascript" src="' . file_create_url(build_js_cache(array('core/misc/authorize.js' => $js_items['core/misc/authorize.js'], 'core/misc/batch.js' => $js_items['core/misc/batch.js']))) . '"></script>',
+      '<script type="text/javascript" src="' . file_create_url(build_js_cache(array('core/misc/ajax.js' => $js_items['core/misc/ajax.js'], 'core/misc/autocomplete.js' => $js_items['core/misc/autocomplete.js']))) . '"></script>',
     ));
     $this->assertTrue(strpos($javascript, $expected) > 0, t('JavaScript is aggregated in the expected groups and order.'));
   }
@@ -1395,16 +1397,16 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    */
   function testRenderOrder() {
     // Add a bunch of JavaScript in strange ordering.
-    drupal_add_js('(function($){alert("Weight 5 #1");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => 5));
-    drupal_add_js('(function($){alert("Weight 0 #1");})(jQuery);', array('type' => 'inline', 'scope' => 'footer'));
-    drupal_add_js('(function($){alert("Weight 0 #2");})(jQuery);', array('type' => 'inline', 'scope' => 'footer'));
-    drupal_add_js('(function($){alert("Weight -8 #1");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8));
-    drupal_add_js('(function($){alert("Weight -8 #2");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8));
-    drupal_add_js('(function($){alert("Weight -8 #3");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8));
-    drupal_add_js('http://example.com/example.js?Weight -5 #1', array('type' => 'external', 'scope' => 'footer', 'weight' => -5));
-    drupal_add_js('(function($){alert("Weight -8 #4");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8));
-    drupal_add_js('(function($){alert("Weight 5 #2");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => 5));
-    drupal_add_js('(function($){alert("Weight 0 #3");})(jQuery);', array('type' => 'inline', 'scope' => 'footer'));
+    add_js('(function($){alert("Weight 5 #1");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => 5));
+    add_js('(function($){alert("Weight 0 #1");})(jQuery);', array('type' => 'inline', 'scope' => 'footer'));
+    add_js('(function($){alert("Weight 0 #2");})(jQuery);', array('type' => 'inline', 'scope' => 'footer'));
+    add_js('(function($){alert("Weight -8 #1");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8));
+    add_js('(function($){alert("Weight -8 #2");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8));
+    add_js('(function($){alert("Weight -8 #3");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8));
+    add_js('http://example.com/example.js?Weight -5 #1', array('type' => 'external', 'scope' => 'footer', 'weight' => -5));
+    add_js('(function($){alert("Weight -8 #4");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8));
+    add_js('(function($){alert("Weight 5 #2");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => 5));
+    add_js('(function($){alert("Weight 0 #3");})(jQuery);', array('type' => 'inline', 'scope' => 'footer'));
 
     // Construct the expected result from the regex.
     $expected = array(
@@ -1421,7 +1423,7 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
     );
 
     // Retrieve the rendered JavaScript and test against the regex.
-    $js = drupal_get_js('footer');
+    $js = get_js('footer');
     $matches = array();
     if (preg_match_all('/Weight\s([-0-9]+\s[#0-9]+)/', $js, $matches)) {
       $result = $matches[1];
@@ -1437,10 +1439,10 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    */
   function testRenderDifferentWeight() {
     // JavaScript files are sorted first by group, then by the 'every_page'
-    // flag, then by weight (see drupal_sort_css_js()), so to test the effect of
+    // flag, then by weight (see sort_css_js()), so to test the effect of
     // weight, we need the other two options to be the same.
-    drupal_add_js('core/misc/collapse.js', array('group' => JS_LIBRARY, 'every_page' => TRUE, 'weight' => -21));
-    $javascript = drupal_get_js();
+    add_js('core/misc/collapse.js', array('group' => JS_LIBRARY, 'every_page' => TRUE, 'weight' => -21));
+    $javascript = get_js();
     $this->assertTrue(strpos($javascript, 'core/misc/collapse.js') < strpos($javascript, 'core/misc/jquery.js'), t('Rendering a JavaScript file above jQuery.'));
   }
 
@@ -1451,13 +1453,13 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    */
   function testAlter() {
     // Add both tableselect.js and simpletest.js, with a larger weight on SimpleTest.
-    drupal_add_js('core/misc/tableselect.js');
-    drupal_add_js(drupal_get_path('module', 'simpletest') . '/simpletest.js', array('weight' => 9999));
+    add_js('core/misc/tableselect.js');
+    add_js(get_path('module', 'simpletest') . '/simpletest.js', array('weight' => 9999));
 
     // Render the JavaScript, testing if simpletest.js was altered to be before
     // tableselect.js. See simpletest_js_alter() to see where this alteration
     // takes place.
-    $javascript = drupal_get_js();
+    $javascript = get_js();
     $this->assertTrue(strpos($javascript, 'simpletest.js') < strpos($javascript, 'core/misc/tableselect.js'), t('Altering JavaScript weight through the alter hook.'));
   }
 
@@ -1465,10 +1467,10 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    * Adds a library to the page and tests for both its JavaScript and its CSS.
    */
   function testLibraryRender() {
-    $result = drupal_add_library('system', 'farbtastic');
+    $result = add_library('system', 'farbtastic');
     $this->assertTrue($result !== FALSE, t('Library was added without errors.'));
-    $scripts = drupal_get_js();
-    $styles = drupal_get_css();
+    $scripts = get_js();
+    $styles = get_css();
     $this->assertTrue(strpos($scripts, 'core/misc/farbtastic/farbtastic.js'), t('JavaScript of library was added to the page.'));
     $this->assertTrue(strpos($styles, 'core/misc/farbtastic/farbtastic.css'), t('Stylesheet of library was added to the page.'));
   }
@@ -1480,12 +1482,12 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    */
   function testLibraryAlter() {
     // Verify that common_test altered the title of Farbtastic.
-    $library = drupal_get_library('system', 'farbtastic');
+    $library = get_library('system', 'farbtastic');
     $this->assertEqual($library['title'], 'Farbtastic: Altered Library', t('Registered libraries were altered.'));
 
     // common_test_library_info_alter() also added a dependency on jQuery Form.
-    drupal_add_library('system', 'farbtastic');
-    $scripts = drupal_get_js();
+    add_library('system', 'farbtastic');
+    $scripts = get_js();
     $this->assertTrue(strpos($scripts, 'core/misc/jquery.form.js'), t('Altered library dependencies are added to the page.'));
   }
 
@@ -1495,7 +1497,7 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    * @see common_test_library_info()
    */
   function testLibraryNameConflicts() {
-    $farbtastic = drupal_get_library('common_test', 'farbtastic');
+    $farbtastic = get_library('common_test', 'farbtastic');
     $this->assertEqual($farbtastic['title'], 'Custom Farbtastic Library', t('Alternative libraries can be added to the page.'));
   }
 
@@ -1503,13 +1505,13 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    * Tests non-existing libraries.
    */
   function testLibraryUnknown() {
-    $result = drupal_get_library('unknown', 'unknown');
+    $result = get_library('unknown', 'unknown');
     $this->assertFalse($result, t('Unknown library returned FALSE.'));
-    drupal_static_reset('drupal_get_library');
+    drupal_static_reset('Drupal\get_library');
 
-    $result = drupal_add_library('unknown', 'unknown');
+    $result = add_library('unknown', 'unknown');
     $this->assertFalse($result, t('Unknown library returned FALSE.'));
-    $scripts = drupal_get_js();
+    $scripts = get_js();
     $this->assertTrue(strpos($scripts, 'unknown') === FALSE, t('Unknown library was not added to the page.'));
   }
 
@@ -1519,27 +1521,27 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
   function testAttachedLibrary() {
     $element['#attached']['library'][] = array('system', 'farbtastic');
     drupal_render($element);
-    $scripts = drupal_get_js();
+    $scripts = get_js();
     $this->assertTrue(strpos($scripts, 'core/misc/farbtastic/farbtastic.js'), t('The attached_library property adds the additional libraries.'));
   }
 
   /**
-   * Tests retrieval of libraries via drupal_get_library().
+   * Tests retrieval of libraries via get_library().
    */
   function testGetLibrary() {
     // Retrieve all libraries registered by a module.
-    $libraries = drupal_get_library('common_test');
+    $libraries = get_library('common_test');
     $this->assertTrue(isset($libraries['farbtastic']), t('Retrieved all module libraries.'));
     // Retrieve all libraries for a module not implementing hook_library_info().
     // Note: This test installs Locale module.
-    $libraries = drupal_get_library('locale');
+    $libraries = get_library('locale');
     $this->assertEqual($libraries, array(), t('Retrieving libraries from a module not implementing hook_library_info() returns an emtpy array.'));
 
     // Retrieve a specific library by module and name.
-    $farbtastic = drupal_get_library('common_test', 'farbtastic');
+    $farbtastic = get_library('common_test', 'farbtastic');
     $this->assertEqual($farbtastic['version'], '5.3', t('Retrieved a single library.'));
     // Retrieve a non-existing library by module and name.
-    $farbtastic = drupal_get_library('common_test', 'foo');
+    $farbtastic = get_library('common_test', 'foo');
     $this->assertIdentical($farbtastic, FALSE, t('Retrieving a non-existing library returns FALSE.'));
   }
 
@@ -1550,14 +1552,14 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
   function testAddJsFileWithQueryString() {
     $this->drupalGet('common-test/query-string');
     $query_string = variable_get('css_js_query_string', '0');
-    $this->assertRaw(drupal_get_path('module', 'node') . '/node.js?' . $query_string, t('Query string was appended correctly to js.'));
+    $this->assertRaw(get_path('module', 'node') . '/node.js?' . $query_string, t('Query string was appended correctly to js.'));
   }
 }
 
 /**
  * Tests for drupal_render().
  */
-class CommonDrupalRenderTestCase extends DrupalWebTestCase {
+class CommonDrupalRenderTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'drupal_render()',
@@ -1631,9 +1633,9 @@ class CommonDrupalRenderTestCase extends DrupalWebTestCase {
 
     // Create an element with a child and subchild.  Each element loads a
     // different JavaScript file using #attached.
-    $parent_js = drupal_get_path('module', 'user') . '/user.js';
-    $child_js = drupal_get_path('module', 'forum') . '/forum.js';
-    $subchild_js = drupal_get_path('module', 'book') . '/book.js';
+    $parent_js = get_path('module', 'user') . '/user.js';
+    $child_js = get_path('module', 'forum') . '/forum.js';
+    $subchild_js = get_path('module', 'book') . '/book.js';
     $element = array(
       '#type' => 'fieldset',
       '#cache' => array(
@@ -1654,16 +1656,16 @@ class CommonDrupalRenderTestCase extends DrupalWebTestCase {
 
     // Render the element and verify the presence of #attached JavaScript.
     drupal_render($element);
-    $scripts = drupal_get_js();
+    $scripts = get_js();
     $this->assertTrue(strpos($scripts, $parent_js), t('The element #attached JavaScript was included.'));
     $this->assertTrue(strpos($scripts, $child_js), t('The child #attached JavaScript was included.'));
     $this->assertTrue(strpos($scripts, $subchild_js), t('The subchild #attached JavaScript was included.'));
 
     // Load the element from cache and verify the presence of the #attached
     // JavaScript.
-    drupal_static_reset('drupal_add_js');
-    $this->assertTrue(drupal_render_cache_get($element), t('The element was retrieved from cache.'));
-    $scripts = drupal_get_js();
+    drupal_static_reset('Drupal\add_js');
+    $this->assertTrue(render_cache_get($element), t('The element was retrieved from cache.'));
+    $scripts = get_js();
     $this->assertTrue(strpos($scripts, $parent_js), t('The element #attached JavaScript was included when loading from cache.'));
     $this->assertTrue(strpos($scripts, $child_js), t('The child #attached JavaScript was included when loading from cache.'));
     $this->assertTrue(strpos($scripts, $subchild_js), t('The subchild #attached JavaScript was included when loading from cache.'));
@@ -1806,7 +1808,7 @@ class CommonDrupalRenderTestCase extends DrupalWebTestCase {
     $error = array(
       '%type' => 'User error',
       '!message' => '"child" is an invalid render array key',
-      '%function' => 'element_children()',
+      '%function' => 'Drupal\element_children()',
     );
     $message = t('%type: !message in %function (line ', $error);
 
@@ -1824,7 +1826,7 @@ class CommonDrupalRenderTestCase extends DrupalWebTestCase {
       . '<hr />' . $this->drupalGetContent()
     );
 
-    // @see DrupalWebTestCase::xpath()
+    // @see WebTestCase::xpath()
     $xpath = $this->buildXPathQuery($xpath, $xpath_args);
     $element += array('#value' => NULL);
     $this->assertFieldByXPath($xpath, $element['#value'], t('#type @type was properly rendered.', array(
@@ -1867,7 +1869,7 @@ class CommonDrupalRenderTestCase extends DrupalWebTestCase {
 /**
  * Tests URL validation by valid_url().
  */
-class CommonValidUrlUnitTestCase extends DrupalUnitTestCase {
+class CommonValidUrlUnitTestCase extends UnitTestCase {
   public static function getInfo() {
     return array(
       'name' => 'URL validation',
@@ -1973,13 +1975,13 @@ class CommonValidUrlUnitTestCase extends DrupalUnitTestCase {
 }
 
 /**
- * Tests writing of data records with drupal_write_record().
+ * Tests writing of data records with write_record().
  */
-class CommonDrupalWriteRecordTestCase extends DrupalWebTestCase {
+class CommonDrupalWriteRecordTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Data record write functionality',
-      'description' => 'Tests writing of data records with drupal_write_record().',
+      'description' => 'Tests writing of data records with write_record().',
       'group' => 'Common',
     );
   }
@@ -1989,21 +1991,21 @@ class CommonDrupalWriteRecordTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Test the drupal_write_record() API function.
+   * Test the write_record() API function.
    */
   function testDrupalWriteRecord() {
     // Insert a record with no columns populated.
     $record = array();
-    $insert_result = drupal_write_record('test', $record);
-    $this->assertTrue($insert_result == SAVED_NEW, t('Correct value returned when an empty record is inserted with drupal_write_record().'));
+    $insert_result = write_record('test', $record);
+    $this->assertTrue($insert_result == SAVED_NEW, t('Correct value returned when an empty record is inserted with write_record().'));
 
     // Insert a record - no columns allow NULL values.
     $person = new stdClass();
     $person->name = 'John';
     $person->unknown_column = 123;
-    $insert_result = drupal_write_record('test', $person);
-    $this->assertTrue($insert_result == SAVED_NEW, t('Correct value returned when a record is inserted with drupal_write_record() for a table with a single-field primary key.'));
-    $this->assertTrue(isset($person->id), t('Primary key is set on record created with drupal_write_record().'));
+    $insert_result = write_record('test', $person);
+    $this->assertTrue($insert_result == SAVED_NEW, t('Correct value returned when a record is inserted with write_record() for a table with a single-field primary key.'));
+    $this->assertTrue(isset($person->id), t('Primary key is set on record created with write_record().'));
     $this->assertIdentical($person->age, 0, t('Age field set to default value.'));
     $this->assertIdentical($person->job, 'Undefined', t('Job field set to default value.'));
 
@@ -2018,8 +2020,8 @@ class CommonDrupalWriteRecordTestCase extends DrupalWebTestCase {
     $person->name = 'Peter';
     $person->age = 27;
     $person->job = NULL;
-    $update_result = drupal_write_record('test', $person, array('id'));
-    $this->assertTrue($update_result == SAVED_UPDATED, t('Correct value returned when a record updated with drupal_write_record() for table with single-field primary key.'));
+    $update_result = write_record('test', $person, array('id'));
+    $this->assertTrue($update_result == SAVED_UPDATED, t('Correct value returned when a record updated with write_record() for table with single-field primary key.'));
 
     // Verify that the record was updated.
     $result = db_query("SELECT * FROM {test} WHERE id = :id", array(':id' => $person->id))->fetchObject();
@@ -2032,8 +2034,8 @@ class CommonDrupalWriteRecordTestCase extends DrupalWebTestCase {
     $person->name = 'Ringo';
     $person->age = NULL;
     $person->job = NULL;
-    $insert_result = drupal_write_record('test', $person);
-    $this->assertTrue(isset($person->id), t('Primary key is set on record created with drupal_write_record().'));
+    $insert_result = write_record('test', $person);
+    $this->assertTrue(isset($person->id), t('Primary key is set on record created with write_record().'));
     $result = db_query("SELECT * FROM {test} WHERE id = :id", array(':id' => $person->id))->fetchObject();
     $this->assertIdentical($result->name, 'Ringo', t('Name field set.'));
     $this->assertIdentical($result->age, '0', t('Age field set.'));
@@ -2043,8 +2045,8 @@ class CommonDrupalWriteRecordTestCase extends DrupalWebTestCase {
     $person = new stdClass();
     $person->name = 'Paul';
     $person->age = NULL;
-    $insert_result = drupal_write_record('test_null', $person);
-    $this->assertTrue(isset($person->id), t('Primary key is set on record created with drupal_write_record().'));
+    $insert_result = write_record('test_null', $person);
+    $this->assertTrue(isset($person->id), t('Primary key is set on record created with write_record().'));
     $result = db_query("SELECT * FROM {test_null} WHERE id = :id", array(':id' => $person->id))->fetchObject();
     $this->assertIdentical($result->name, 'Paul', t('Name field set.'));
     $this->assertIdentical($result->age, NULL, t('Age field set.'));
@@ -2052,8 +2054,8 @@ class CommonDrupalWriteRecordTestCase extends DrupalWebTestCase {
     // Insert a record - do not specify the value of a column that allows NULL.
     $person = new stdClass();
     $person->name = 'Meredith';
-    $insert_result = drupal_write_record('test_null', $person);
-    $this->assertTrue(isset($person->id), t('Primary key is set on record created with drupal_write_record().'));
+    $insert_result = write_record('test_null', $person);
+    $this->assertTrue(isset($person->id), t('Primary key is set on record created with write_record().'));
     $this->assertIdentical($person->age, 0, t('Age field set to default value.'));
     $result = db_query("SELECT * FROM {test_null} WHERE id = :id", array(':id' => $person->id))->fetchObject();
     $this->assertIdentical($result->name, 'Meredith', t('Name field set.'));
@@ -2062,7 +2064,7 @@ class CommonDrupalWriteRecordTestCase extends DrupalWebTestCase {
     // Update the newly created record.
     $person->name = 'Mary';
     $person->age = NULL;
-    $update_result = drupal_write_record('test_null', $person, array('id'));
+    $update_result = write_record('test_null', $person, array('id'));
     $result = db_query("SELECT * FROM {test_null} WHERE id = :id", array(':id' => $person->id))->fetchObject();
     $this->assertIdentical($result->name, 'Mary', t('Name field set.'));
     $this->assertIdentical($result->age, NULL, t('Age field set.'));
@@ -2070,27 +2072,27 @@ class CommonDrupalWriteRecordTestCase extends DrupalWebTestCase {
     // Insert a record - the "data" column should be serialized.
     $person = new stdClass();
     $person->name = 'Dave';
-    $update_result = drupal_write_record('test_serialized', $person);
+    $update_result = write_record('test_serialized', $person);
     $result = db_query("SELECT * FROM {test_serialized} WHERE id = :id", array(':id' => $person->id))->fetchObject();
     $this->assertIdentical($result->name, 'Dave', t('Name field set.'));
     $this->assertIdentical($result->info, NULL, t('Info field set.'));
 
     $person->info = array();
-    $update_result = drupal_write_record('test_serialized', $person, array('id'));
+    $update_result = write_record('test_serialized', $person, array('id'));
     $result = db_query("SELECT * FROM {test_serialized} WHERE id = :id", array(':id' => $person->id))->fetchObject();
     $this->assertIdentical(unserialize($result->info), array(), t('Info field updated.'));
 
     // Update the serialized record.
     $data = array('foo' => 'bar', 1 => 2, 'empty' => '', 'null' => NULL);
     $person->info = $data;
-    $update_result = drupal_write_record('test_serialized', $person, array('id'));
+    $update_result = write_record('test_serialized', $person, array('id'));
     $result = db_query("SELECT * FROM {test_serialized} WHERE id = :id", array(':id' => $person->id))->fetchObject();
     $this->assertIdentical(unserialize($result->info), $data, t('Info field updated.'));
 
     // Run an update query where no field values are changed. The database
     // layer should return zero for number of affected rows, but
     // db_write_record() should still return SAVED_UPDATED.
-    $update_result = drupal_write_record('test_null', $person, array('id'));
+    $update_result = write_record('test_null', $person, array('id'));
     $this->assertTrue($update_result == SAVED_UPDATED, t('Correct value returned when a valid update is run without changing any values.'));
 
     // Insert an object record for a table with a multi-field primary key.
@@ -2098,12 +2100,12 @@ class CommonDrupalWriteRecordTestCase extends DrupalWebTestCase {
     $node_access->nid = mt_rand();
     $node_access->gid = mt_rand();
     $node_access->realm = $this->randomName();
-    $insert_result = drupal_write_record('node_access', $node_access);
-    $this->assertTrue($insert_result == SAVED_NEW, t('Correct value returned when a record is inserted with drupal_write_record() for a table with a multi-field primary key.'));
+    $insert_result = write_record('node_access', $node_access);
+    $this->assertTrue($insert_result == SAVED_NEW, t('Correct value returned when a record is inserted with write_record() for a table with a multi-field primary key.'));
 
     // Update the record.
-    $update_result = drupal_write_record('node_access', $node_access, array('nid', 'gid', 'realm'));
-    $this->assertTrue($update_result == SAVED_UPDATED, t('Correct value returned when a record is updated with drupal_write_record() for a table with a multi-field primary key.'));
+    $update_result = write_record('node_access', $node_access, array('nid', 'gid', 'realm'));
+    $this->assertTrue($update_result == SAVED_UPDATED, t('Correct value returned when a record is updated with write_record() for a table with a multi-field primary key.'));
   }
 
 }
@@ -2111,13 +2113,13 @@ class CommonDrupalWriteRecordTestCase extends DrupalWebTestCase {
 /**
  * Tests SimpleTest error and exception collector.
  */
-class CommonSimpleTestErrorCollectorTestCase extends DrupalWebTestCase {
+class CommonSimpleTestErrorCollectorTestCase extends WebTestCase {
 
   /**
    * Errors triggered during the test.
    *
    * Errors are intercepted by the overriden implementation
-   * of DrupalWebTestCase::error below.
+   * of WebTestCase::error below.
    *
    * @var Array
    */
@@ -2144,9 +2146,9 @@ class CommonSimpleTestErrorCollectorTestCase extends DrupalWebTestCase {
     $this->assertEqual(count($this->collectedErrors), 3, t('Three errors were collected'));
 
     if (count($this->collectedErrors) == 3) {
-      $this->assertError($this->collectedErrors[0], 'Notice', 'error_test_generate_warnings()', 'error_test.module', 'Undefined variable: bananas');
-      $this->assertError($this->collectedErrors[1], 'Warning', 'error_test_generate_warnings()', 'error_test.module', 'Division by zero');
-      $this->assertError($this->collectedErrors[2], 'User warning', 'error_test_generate_warnings()', 'error_test.module', 'Drupal is awesome');
+      $this->assertError($this->collectedErrors[0], 'Notice', 'Drupal\error_test_generate_warnings()', 'error_test.module', 'Undefined variable: bananas');
+      $this->assertError($this->collectedErrors[1], 'Warning', 'Drupal\error_test_generate_warnings()', 'error_test.module', 'Division by zero');
+      $this->assertError($this->collectedErrors[2], 'User warning', 'Drupal\error_test_generate_warnings()', 'error_test.module', 'Drupal is awesome');
     }
     else {
       // Give back the errors to the log report.
@@ -2192,7 +2194,7 @@ class CommonSimpleTestErrorCollectorTestCase extends DrupalWebTestCase {
   function assertError($error, $group, $function, $file, $message = NULL) {
     $this->assertEqual($error['group'], $group, t("Group was %group", array('%group' => $group)));
     $this->assertEqual($error['caller']['function'], $function, t("Function was %function", array('%function' => $function)));
-    $this->assertEqual(drupal_basename($error['caller']['file']), $file, t("File was %file", array('%file' => $file)));
+    $this->assertEqual(basename($error['caller']['file']), $file, t("File was %file", array('%file' => $file)));
     if (isset($message)) {
       $this->assertEqual($error['message'], $message, t("Message was %message", array('%message' => $message)));
     }
@@ -2200,13 +2202,13 @@ class CommonSimpleTestErrorCollectorTestCase extends DrupalWebTestCase {
 }
 
 /**
- * Tests the drupal_parse_info_file() API function.
+ * Tests the parse_info_file() API function.
  */
-class CommonDrupalParseInfoFileTestCase extends DrupalWebTestCase {
+class CommonDrupalParseInfoFileTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Parsing .info files',
-      'description' => 'Tests the drupal_parse_info_file() API function.',
+      'description' => 'Tests the parse_info_file() API function.',
       'group' => 'Common',
     );
   }
@@ -2215,7 +2217,7 @@ class CommonDrupalParseInfoFileTestCase extends DrupalWebTestCase {
    * Parse an example .info file an verify the results.
    */
   function testParseInfoFile() {
-    $info_values = drupal_parse_info_file(drupal_get_path('module', 'simpletest') . '/tests/common_test_info.txt');
+    $info_values = parse_info_file(get_path('module', 'simpletest') . '/tests/common_test_info.txt');
     $this->assertEqual($info_values['simple_string'], 'A simple string', t('Simple string value was parsed correctly.'), t('System'));
     $this->assertEqual($info_values['simple_constant'], WATCHDOG_INFO, t('Constant value was parsed correctly.'), t('System'));
     $this->assertEqual($info_values['double_colon'], 'dummyClassName::', t('Value containing double-colon was parsed correctly.'), t('System'));
@@ -2223,9 +2225,9 @@ class CommonDrupalParseInfoFileTestCase extends DrupalWebTestCase {
 }
 
 /**
- * Tests scanning system directories in drupal_system_listing().
+ * Tests scanning system directories in system_listing().
  */
-class CommonDrupalSystemListingTestCase extends DrupalWebTestCase {
+class CommonDrupalSystemListingTestCase extends WebTestCase {
   /**
    * Use the testing profile; this is needed for testDirectoryPrecedence().
    */
@@ -2234,7 +2236,7 @@ class CommonDrupalSystemListingTestCase extends DrupalWebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Drupal system listing',
-      'description' => 'Tests scanning system directories in drupal_system_listing().',
+      'description' => 'Tests scanning system directories in system_listing().',
       'group' => 'Common',
     );
   }
@@ -2267,13 +2269,13 @@ class CommonDrupalSystemListingTestCase extends DrupalWebTestCase {
     foreach ($expected_directories as $module => $directories) {
       foreach ($directories as $directory) {
         $filename = "$directory/$module/$module.module";
-        $this->assertTrue(file_exists(DRUPAL_ROOT . '/' . $filename), t('@filename exists.', array('@filename' => $filename)));
+        $this->assertTrue(file_exists(ROOT . '/' . $filename), t('@filename exists.', array('@filename' => $filename)));
       }
     }
 
     // Now scan the directories and check that the files take precedence as
     // expected.
-    $files = drupal_system_listing('/\.module$/', 'modules', 'name', 1);
+    $files = system_listing('/\.module$/', 'modules', 'name', 1);
     foreach ($expected_directories as $module => $directories) {
       $expected_directory = array_shift($directories);
       $expected_filename = "$expected_directory/$module/$module.module";
@@ -2285,7 +2287,7 @@ class CommonDrupalSystemListingTestCase extends DrupalWebTestCase {
 /**
  * Tests the format_date() function.
  */
-class CommonFormatDateTestCase extends DrupalWebTestCase {
+class CommonFormatDateTestCase extends WebTestCase {
 
   /**
    * Arbitrary langcode for a custom language.
@@ -2375,14 +2377,14 @@ class CommonFormatDateTestCase extends DrupalWebTestCase {
     $this->drupalPost('user/' . $test_user->uid . '/edit', $edit, t('Save'));
 
     // Disable session saving as we are about to modify the global $user.
-    drupal_save_session(FALSE);
+    save_session(FALSE);
     // Save the original user and language and then replace it with the test user and language.
     $real_user = $user;
     $user = user_load($test_user->uid, TRUE);
     $real_language = $language->langcode;
     $language->langcode = $user->language;
     // Simulate a Drupal bootstrap with the logged-in user.
-    date_default_timezone_set(drupal_get_user_timezone());
+    date_default_timezone_set(get_user_timezone());
 
     $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', t('Test a different language.'));
     $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London'), 'Monday, 26-Mar-07 01:00:00 BST', t('Test a different time zone.'));
@@ -2396,37 +2398,37 @@ class CommonFormatDateTestCase extends DrupalWebTestCase {
     $user = $real_user;
     $language->langcode = $real_language;
     // Restore default time zone.
-    date_default_timezone_set(drupal_get_user_timezone());
-    drupal_save_session(TRUE);
+    date_default_timezone_set(get_user_timezone());
+    save_session(TRUE);
   }
 }
 
 /**
- * Tests the drupal_attributes() functionality.
+ * Tests the attributes() functionality.
  */
-class CommonDrupalAttributesUnitTestCase extends DrupalUnitTestCase {
+class CommonDrupalAttributesUnitTestCase extends UnitTestCase {
   public static function getInfo() {
     return array(
       'name' => 'HTML Attributes',
-      'description' => 'Tests the drupal_attributes() functionality.',
+      'description' => 'Tests the attributes() functionality.',
       'group' => 'Common',
     );
   }
 
   /**
-   * Tests that drupal_html_class() cleans the class name properly.
+   * Tests that html_class() cleans the class name properly.
    */
   function testDrupalAttributes() {
     // Verify that special characters are HTML encoded.
-    $this->assertIdentical(drupal_attributes(array('title' => '&"\'<>')), ' title="&amp;&quot;&#039;&lt;&gt;"', t('HTML encode attribute values.'));
+    $this->assertIdentical(attributes(array('title' => '&"\'<>')), ' title="&amp;&quot;&#039;&lt;&gt;"', t('HTML encode attribute values.'));
 
     // Verify multi-value attributes are concatenated with spaces.
     $attributes = array('class' => array('first', 'last'));
-    $this->assertIdentical(drupal_attributes(array('class' => array('first', 'last'))), ' class="first last"', t('Concatenate multi-value attributes.'));
+    $this->assertIdentical(attributes(array('class' => array('first', 'last'))), ' class="first last"', t('Concatenate multi-value attributes.'));
 
     // Verify empty attribute values are rendered.
-    $this->assertIdentical(drupal_attributes(array('alt' => '')), ' alt=""', t('Empty attribute value #1.'));
-    $this->assertIdentical(drupal_attributes(array('alt' => NULL)), ' alt=""', t('Empty attribute value #2.'));
+    $this->assertIdentical(attributes(array('alt' => '')), ' alt=""', t('Empty attribute value #1.'));
+    $this->assertIdentical(attributes(array('alt' => NULL)), ' alt=""', t('Empty attribute value #2.'));
 
     // Verify multiple attributes are rendered.
     $attributes = array(
@@ -2434,17 +2436,17 @@ class CommonDrupalAttributesUnitTestCase extends DrupalUnitTestCase {
       'class' => array('first', 'last'),
       'alt' => 'Alternate',
     );
-    $this->assertIdentical(drupal_attributes($attributes), ' id="id-test" class="first last" alt="Alternate"', t('Multiple attributes.'));
+    $this->assertIdentical(attributes($attributes), ' id="id-test" class="first last" alt="Alternate"', t('Multiple attributes.'));
 
     // Verify empty attributes array is rendered.
-    $this->assertIdentical(drupal_attributes(array()), '', t('Empty attributes array.'));
+    $this->assertIdentical(attributes(array()), '', t('Empty attributes array.'));
   }
 }
 
 /**
  * Tests the various drupal_array_* helper functions.
  */
-class CommonDrupalArrayUnitTest extends DrupalUnitTestCase {
+class CommonDrupalArrayUnitTest extends UnitTestCase {
 
   /**
    * Form array to check.
@@ -2481,26 +2483,26 @@ class CommonDrupalArrayUnitTest extends DrupalUnitTestCase {
    */
   function testGet() {
     // Verify getting a value of a nested element.
-    $value = drupal_array_get_nested_value($this->form, $this->parents);
+    $value = array_get_nested_value($this->form, $this->parents);
     $this->assertEqual($value['#value'], 'Nested element', 'Nested element value found.');
 
     // Verify changing a value of a nested element by reference.
-    $value = &drupal_array_get_nested_value($this->form, $this->parents);
+    $value = &array_get_nested_value($this->form, $this->parents);
     $value['#value'] = 'New value';
-    $value = drupal_array_get_nested_value($this->form, $this->parents);
+    $value = array_get_nested_value($this->form, $this->parents);
     $this->assertEqual($value['#value'], 'New value', 'Nested element value was changed by reference.');
     $this->assertEqual($this->form['fieldset']['element']['#value'], 'New value', 'Nested element value was changed by reference.');
 
     // Verify that an existing key is reported back.
     $key_exists = NULL;
-    drupal_array_get_nested_value($this->form, $this->parents, $key_exists);
+    array_get_nested_value($this->form, $this->parents, $key_exists);
     $this->assertIdentical($key_exists, TRUE, 'Existing key found.');
 
     // Verify that a non-existing key is reported back and throws no errors.
     $key_exists = NULL;
     $parents = $this->parents;
     $parents[] = 'foo';
-    drupal_array_get_nested_value($this->form, $parents, $key_exists);
+    array_get_nested_value($this->form, $parents, $key_exists);
     $this->assertIdentical($key_exists, FALSE, 'Non-existing key not found.');
   }
 
@@ -2514,7 +2516,7 @@ class CommonDrupalArrayUnitTest extends DrupalUnitTestCase {
     );
 
     // Verify setting the value of a nested element.
-    drupal_array_set_nested_value($this->form, $this->parents, $new_value);
+    array_set_nested_value($this->form, $this->parents, $new_value);
     $this->assertEqual($this->form['fieldset']['element']['#value'], 'New value', 'Changed nested element value found.');
     $this->assertIdentical($this->form['fieldset']['element']['#required'], TRUE, 'New nested element value found.');
   }
@@ -2528,13 +2530,13 @@ class CommonDrupalArrayUnitTest extends DrupalUnitTestCase {
     $key_existed = NULL;
     $parents = $this->parents;
     $parents[] = 'foo';
-    drupal_array_unset_nested_value($this->form, $parents, $key_existed);
+    array_unset_nested_value($this->form, $parents, $key_existed);
     $this->assertTrue(isset($this->form['fieldset']['element']['#value']), 'Outermost nested element key still exists.');
     $this->assertIdentical($key_existed, FALSE, 'Non-existing key not found.');
 
     // Verify unsetting a nested element.
     $key_existed = NULL;
-    drupal_array_unset_nested_value($this->form, $this->parents, $key_existed);
+    array_unset_nested_value($this->form, $this->parents, $key_existed);
     $this->assertFalse(isset($this->form['fieldset']['element']), 'Removed nested element not found.');
     $this->assertIdentical($key_existed, TRUE, 'Existing key was found.');
   }
@@ -2544,19 +2546,19 @@ class CommonDrupalArrayUnitTest extends DrupalUnitTestCase {
    */
   function testKeyExists() {
     // Verify that existing key is found.
-    $this->assertIdentical(drupal_array_nested_key_exists($this->form, $this->parents), TRUE, 'Nested key found.');
+    $this->assertIdentical(array_nested_key_exists($this->form, $this->parents), TRUE, 'Nested key found.');
 
     // Verify that non-existing keys are not found.
     $parents = $this->parents;
     $parents[] = 'foo';
-    $this->assertIdentical(drupal_array_nested_key_exists($this->form, $parents), FALSE, 'Non-existing nested key not found.');
+    $this->assertIdentical(array_nested_key_exists($this->form, $parents), FALSE, 'Non-existing nested key not found.');
   }
 }
 
 /**
  * Tests the drupal_json_encode() and drupal_json_decode() functions.
  */
-class CommonJSONUnitTestCase extends DrupalUnitTestCase {
+class CommonJSONUnitTestCase extends UnitTestCase {
   public static function getInfo() {
     return array(
       'name' => 'JSON',
@@ -2618,19 +2620,19 @@ class CommonJSONUnitTestCase extends DrupalUnitTestCase {
 }
 
 /**
- * Basic tests for drupal_add_feed().
+ * Basic tests for add_feed().
  */
-class CommonDrupalAddFeedTestCase extends DrupalWebTestCase {
+class CommonAddFeedTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
-      'name' => 'drupal_add_feed() tests',
-      'description' => 'Make sure that drupal_add_feed() works correctly with various constructs.',
+      'name' => 'add_feed() tests',
+      'description' => 'Make sure that add_feed() works correctly with various constructs.',
       'group' => 'Common',
     );
   }
 
   /**
-   * Test drupal_add_feed() with paths, URLs, and titles.
+   * Test add_feed() with paths, URLs, and titles.
    */
   function testBasicFeedAddNoTitle() {
     $path = $this->randomName(12);
@@ -2641,10 +2643,10 @@ class CommonDrupalAddFeedTestCase extends DrupalWebTestCase {
     $external_for_title = 'http://' . $this->randomName(12) . '/' . $this->randomName(12);
     $fully_qualified_for_title = url($this->randomName(12), array('absolute' => TRUE));
 
-    // Possible permutations of drupal_add_feed() to test.
-    // - 'input_url': the path passed to drupal_add_feed(),
+    // Possible permutations of add_feed() to test.
+    // - 'input_url': the path passed to add_feed(),
     // - 'output_url': the expected URL to be found in the header.
-    // - 'title' == the title of the feed as passed into drupal_add_feed().
+    // - 'title' == the title of the feed as passed into add_feed().
     $urls = array(
       'path without title' => array(
         'input_url' => $path,
@@ -2679,10 +2681,10 @@ class CommonDrupalAddFeedTestCase extends DrupalWebTestCase {
     );
 
     foreach ($urls as $description => $feed_info) {
-      drupal_add_feed($feed_info['input_url'], $feed_info['title']);
+      add_feed($feed_info['input_url'], $feed_info['title']);
     }
 
-    $this->drupalSetContent(drupal_get_html_head());
+    $this->drupalSetContent(get_html_head());
     foreach ($urls as $description => $feed_info) {
       $this->assertPattern($this->urlToRSSLinkPattern($feed_info['output_url'], $feed_info['title']), t('Found correct feed header for %description', array('%description' => $description)));
     }
diff --git a/core/modules/simpletest/tests/common_test.module b/core/modules/simpletest/tests/common_test.module
index e1cfdf2..961b9d5 100644
--- a/core/modules/simpletest/tests/common_test.module
+++ b/core/modules/simpletest/tests/common_test.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -9,34 +11,34 @@
  * Implements hook_menu().
  */
 function common_test_menu() {
-  $items['common-test/drupal_goto'] = array(
-    'title' => 'Drupal Goto',
-    'page callback' => 'common_test_drupal_goto_land',
+  $items['common-test/redirect'] = array(
+    'title' => 'Drupal Redirect',
+    'page callback' => 'common_test_redirect_land',
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );
-  $items['common-test/drupal_goto/fail'] = array(
-    'title' => 'Drupal Goto',
-    'page callback' => 'common_test_drupal_goto_land_fail',
+  $items['common-test/redirect/fail'] = array(
+    'title' => 'Drupal Redirect',
+    'page callback' => 'common_test_redirect_land_fail',
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );
-  $items['common-test/drupal_goto/redirect'] = array(
-    'title' => 'Drupal Goto',
-    'page callback' => 'common_test_drupal_goto_redirect',
+  $items['common-test/redirect/redirect'] = array(
+    'title' => 'Drupal Redirect',
+    'page callback' => 'common_test_redirect_redirect',
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );
-  $items['common-test/drupal_goto/redirect_advanced'] = array(
-    'title' => 'Drupal Goto',
-    'page callback' => 'common_test_drupal_goto_redirect_advanced',
+  $items['common-test/redirect/redirect_advanced'] = array(
+    'title' => 'Drupal Redirect',
+    'page callback' => 'common_test_redirect_redirect_advanced',
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );
-  $items['common-test/drupal_goto/redirect_fail'] = array(
-    'title' => 'Drupal Goto Failure',
-    'page callback' => 'drupal_goto',
-    'page arguments' => array('common-test/drupal_goto/fail'),
+  $items['common-test/redirect/redirect_fail'] = array(
+    'title' => 'Drupal Redirect Failure',
+    'page callback' => 'redirect',
+    'page arguments' => array('common-test/redirect/fail'),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );
@@ -62,39 +64,39 @@ function common_test_menu() {
 }
 
 /**
- * Redirect using drupal_goto().
+ * Redirect using redirect().
  */
-function common_test_drupal_goto_redirect() {
-  drupal_goto('common-test/drupal_goto');
+function common_test_redirect_redirect() {
+  redirect('common-test/redirect');
 }
 
 /**
- * Redirect using drupal_goto().
+ * Redirect using redirect().
  */
-function common_test_drupal_goto_redirect_advanced() {
-  drupal_goto('common-test/drupal_goto', array('query' => array('foo' => '123')), 301);
+function common_test_redirect_redirect_advanced() {
+  redirect('common-test/redirect', array('query' => array('foo' => '123')), 301);
 }
 
 /**
- * Landing page for drupal_goto().
+ * Landing page for redirect().
  */
-function common_test_drupal_goto_land() {
-  print "drupal_goto";
+function common_test_redirect_land() {
+  print "redirect";
 }
 
 /**
- * Fail landing page for drupal_goto().
+ * Fail landing page for redirect().
  */
-function common_test_drupal_goto_land_fail() {
-  print "drupal_goto_fail";
+function common_test_redirect_land_fail() {
+  print "redirect_fail";
 }
 
 /**
- * Implements hook_drupal_goto_alter().
+ * Implements hook_redirect_alter().
  */
-function common_test_drupal_goto_alter(&$path, &$options, &$http_response_code) {
-  if ($path == 'common-test/drupal_goto/fail') {
-    $path = 'common-test/drupal_goto/redirect';
+function common_test_redirect_alter(&$path, &$options, &$http_response_code) {
+  if ($path == 'common-test/redirect/fail') {
+    $path = 'common-test/redirect/redirect';
   }
 }
 
@@ -102,7 +104,7 @@ function common_test_drupal_goto_alter(&$path, &$options, &$http_response_code)
  * Print destination query parameter.
  */
 function common_test_destination() {
-  $destination = drupal_get_destination();
+  $destination = get_destination();
   print "The destination: " . check_plain($destination['destination']);
 }
 
@@ -125,7 +127,7 @@ function common_test_drupal_render_invalid_keys() {
 /**
  * Implements hook_TYPE_alter().
  */
-function common_test_drupal_alter_alter(&$data, &$arg2 = NULL, &$arg3 = NULL) {
+function common_test_alter_alter(&$data, &$arg2 = NULL, &$arg3 = NULL) {
   // Alter first argument.
   if (is_array($data)) {
     $data['foo'] = 'Drupal';
@@ -156,10 +158,10 @@ function common_test_drupal_alter_alter(&$data, &$arg2 = NULL, &$arg3 = NULL) {
 /**
  * Implements hook_TYPE_alter() on behalf of Bartik theme.
  *
- * Same as common_test_drupal_alter_alter(), but here, we verify that themes
+ * Same as common_test_alter_alter(), but here, we verify that themes
  * can also alter and come last.
  */
-function bartik_drupal_alter_alter(&$data, &$arg2 = NULL, &$arg3 = NULL) {
+function bartik_alter_alter(&$data, &$arg2 = NULL, &$arg3 = NULL) {
   // Alter first argument.
   if (is_array($data)) {
     $data['foo'] .= ' theme';
@@ -190,25 +192,25 @@ function bartik_drupal_alter_alter(&$data, &$arg2 = NULL, &$arg3 = NULL) {
 /**
  * Implements hook_TYPE_alter() on behalf of block module.
  *
- * This is for verifying that drupal_alter(array(TYPE1, TYPE2), ...) allows
+ * This is for verifying that alter(array(TYPE1, TYPE2), ...) allows
  * hook_module_implements_alter() to affect the order in which module
  * implementations are executed.
  */
-function block_drupal_alter_foo_alter(&$data, &$arg2 = NULL, &$arg3 = NULL) {
+function block_alter_foo_alter(&$data, &$arg2 = NULL, &$arg3 = NULL) {
   $data['foo'] .= ' block';
 }
 
 /**
  * Implements hook_module_implements_alter().
  *
- * @see block_drupal_alter_foo_alter()
+ * @see block_alter_foo_alter()
  */
 function common_test_module_implements_alter(&$implementations, $hook) {
-  // For drupal_alter(array('drupal_alter', 'drupal_alter_foo'), ...), make the
+  // For alter(array('alter', 'alter_foo'), ...), make the
   // block module implementations run after all the other modules. Note that
-  // when drupal_alter() is called with an array of types, the first type is
+  // when alter() is called with an array of types, the first type is
   // considered primary and controls the module order.
-  if ($hook == 'drupal_alter_alter' && isset($implementations['block'])) {
+  if ($hook == 'alter_alter' && isset($implementations['block'])) {
     $group = $implementations['block'];
     unset($implementations['block']);
     $implementations['block'] = $group;
@@ -269,10 +271,10 @@ function common_test_library_info() {
  * Adds a JavaScript file and a CSS file with a query string appended.
  */
 function common_test_js_and_css_querystring() {
-   drupal_add_js(drupal_get_path('module', 'node') . '/node.js');
-   drupal_add_css(drupal_get_path('module', 'node') . '/node.css');
+   add_js(get_path('module', 'node') . '/node.js');
+   add_css(get_path('module', 'node') . '/node.css');
    // A relative URI may have a query string.
-   drupal_add_css('/' . drupal_get_path('module', 'node') . '/node-fake.css?arg1=value1&arg2=value2');
+   add_css('/' . get_path('module', 'node') . '/node-fake.css?arg1=value1&arg2=value2');
    return '';
 }
 
diff --git a/core/modules/simpletest/tests/common_test_cron_helper.module b/core/modules/simpletest/tests/common_test_cron_helper.module
index 94a2b2c..b813ab8 100644
--- a/core/modules/simpletest/tests/common_test_cron_helper.module
+++ b/core/modules/simpletest/tests/common_test_cron_helper.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 /**
  * @file
  * Helper module for the testCronExceptions in addition to common_test module.
diff --git a/core/modules/simpletest/tests/database_test.install b/core/modules/simpletest/tests/database_test.install
index 4dce2b1..376531c 100644
--- a/core/modules/simpletest/tests/database_test.install
+++ b/core/modules/simpletest/tests/database_test.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/simpletest/tests/database_test.module b/core/modules/simpletest/tests/database_test.module
index 6fac319..62f3248 100644
--- a/core/modules/simpletest/tests/database_test.module
+++ b/core/modules/simpletest/tests/database_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Implements hook_query_alter().
@@ -67,7 +68,7 @@ function database_test_menu() {
   );
   $items['database_test/tablesort_default_sort'] = array(
     'access callback' => TRUE,
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('database_test_theme_tablesort'),
   );
   return $items;
@@ -82,7 +83,7 @@ function database_test_menu() {
  */
 function database_test_db_query_temporary() {
   $table_name = db_query_temporary('SELECT status FROM {system}', array());
-  drupal_json_output(array(
+  json_output(array(
     'table_name' => $table_name,
     'row_count' => db_select($table_name)->countQuery()->execute()->fetchField(),
   ));
@@ -107,7 +108,7 @@ function database_test_even_pager_query($limit) {
 
   $names = $query->execute()->fetchCol();
 
-  drupal_json_output(array(
+  json_output(array(
     'names' => $names,
   ));
   exit;
@@ -131,7 +132,7 @@ function database_test_odd_pager_query($limit) {
 
   $names = $query->execute()->fetchCol();
 
-  drupal_json_output(array(
+  json_output(array(
     'names' => $names,
   ));
   exit;
@@ -160,7 +161,7 @@ function database_test_tablesort() {
   // We need all the results at once to check the sort.
   $tasks = $query->execute()->fetchAll();
 
-  drupal_json_output(array(
+  json_output(array(
     'tasks' => $tasks,
   ));
   exit;
@@ -189,7 +190,7 @@ function database_test_tablesort_first() {
   // We need all the results at once to check the sort.
   $tasks = $query->execute()->fetchAll();
 
-  drupal_json_output(array(
+  json_output(array(
     'tasks' => $tasks,
   ));
   exit;
diff --git a/core/modules/simpletest/tests/database_test.test b/core/modules/simpletest/tests/database_test.test
index 16c09c6..8c893a7 100644
--- a/core/modules/simpletest/tests/database_test.test
+++ b/core/modules/simpletest/tests/database_test.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, PDO, stdClass;
 
 /**
  * Dummy class for fetching into a class.
@@ -15,7 +17,7 @@ class FakeRecord { }
  * Because all database tests share the same test data, we can centralize that
  * here.
  */
-class DatabaseTestCase extends DrupalWebTestCase {
+class DatabaseTestCase extends WebTestCase {
   protected $profile = 'testing';
 
   function setUp() {
@@ -26,11 +28,11 @@ class DatabaseTestCase extends DrupalWebTestCase {
     $modules[] = 'database_test';
     parent::setUp($modules);
 
-    $schema['test'] = drupal_get_schema('test');
-    $schema['test_people'] = drupal_get_schema('test_people');
-    $schema['test_one_blob'] = drupal_get_schema('test_one_blob');
-    $schema['test_two_blobs'] = drupal_get_schema('test_two_blobs');
-    $schema['test_task'] = drupal_get_schema('test_task');
+    $schema['test'] = get_schema('test');
+    $schema['test_people'] = get_schema('test_people');
+    $schema['test_one_blob'] = get_schema('test_one_blob');
+    $schema['test_two_blobs'] = get_schema('test_two_blobs');
+    $schema['test_task'] = get_schema('test_task');
 
     $this->installTables($schema);
 
@@ -61,7 +63,7 @@ class DatabaseTestCase extends DrupalWebTestCase {
    * Set up tables for NULL handling.
    */
   function ensureSampleDataNull() {
-    $schema['test_null'] = drupal_get_schema('test_null');
+    $schema['test_null'] = get_schema('test_null');
     $this->installTables($schema);
 
     db_insert('test_null')
@@ -355,7 +357,7 @@ class DatabaseFetchTestCase extends DatabaseTestCase {
    */
   function testQueryFetchClass() {
     $records = array();
-    $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => 'FakeRecord'));
+    $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => 'Drupal\FakeRecord'));
     foreach ($result as $record) {
       $records[] = $record;
       if ($this->assertTrue($record instanceof FakeRecord, t('Record is an object of class FakeRecord.'))) {
@@ -652,7 +654,7 @@ class DatabaseInsertDefaultsTestCase extends DatabaseTestCase {
     $query = db_insert('test')->useDefaults(array('job'));
     $id = $query->execute();
 
-    $schema = drupal_get_schema('test');
+    $schema = get_schema('test');
 
     $job = db_query('SELECT job FROM {test} WHERE id = :id', array(':id' => $id))->fetchField();
     $this->assertEqual($job, $schema['fields']['job']['default'], t('Default field value is set.'));
@@ -685,7 +687,7 @@ class DatabaseInsertDefaultsTestCase extends DatabaseTestCase {
       ->useDefaults(array('job'));
     $id = $query->execute();
 
-    $schema = drupal_get_schema('test');
+    $schema = get_schema('test');
 
     $job = db_query('SELECT job FROM {test} WHERE id = :id', array(':id' => $id))->fetchField();
     $this->assertEqual($job, $schema['fields']['job']['default'], t('Default field value is set.'));
@@ -2950,7 +2952,7 @@ class DatabaseSerializeQueryTestCase extends DatabaseTestCase {
 /**
  * Range query tests.
  */
-class DatabaseRangeQueryTestCase extends DrupalWebTestCase {
+class DatabaseRangeQueryTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Range query test',
@@ -2981,7 +2983,7 @@ class DatabaseRangeQueryTestCase extends DrupalWebTestCase {
 /**
  * Temporary query tests.
  */
-class DatabaseTemporaryQueryTestCase extends DrupalWebTestCase {
+class DatabaseTemporaryQueryTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Temporary query test',
@@ -3706,7 +3708,7 @@ class DatabaseTransactionTestCase extends DatabaseTestCase {
 /**
  * Check the sequences API.
  */
-class DatabaseNextIdCase extends DrupalWebTestCase {
+class DatabaseNextIdCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => t('Sequences API'),
@@ -3733,7 +3735,7 @@ class DatabaseNextIdCase extends DrupalWebTestCase {
 /**
  * Tests the empty pseudo-statement class.
  */
-class DatabaseEmptyStatementTestCase extends DrupalWebTestCase {
+class DatabaseEmptyStatementTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => t('Empty statement'),
diff --git a/core/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module b/core/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module
index b3d9bbc..66bf2d1 100644
--- a/core/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module
+++ b/core/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module
@@ -1 +1,2 @@
 <?php
+namespace Drupal;
diff --git a/core/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module b/core/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module
index b3d9bbc..66bf2d1 100644
--- a/core/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module
+++ b/core/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module
@@ -1 +1,2 @@
 <?php
+namespace Drupal;
diff --git a/core/modules/simpletest/tests/error.test b/core/modules/simpletest/tests/error.test
index 8c5a848..d5b4e1f 100644
--- a/core/modules/simpletest/tests/error.test
+++ b/core/modules/simpletest/tests/error.test
@@ -1,9 +1,11 @@
 <?php
+namespace Drupal;
+use Exception, PDO, PDOException;
 
 /**
  * Tests Drupal error and exception handlers.
  */
-class DrupalErrorHandlerUnitTest extends DrupalWebTestCase {
+class ErrorHandlerUnitTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Drupal error handlers',
@@ -23,19 +25,19 @@ class DrupalErrorHandlerUnitTest extends DrupalWebTestCase {
     $error_notice = array(
       '%type' => 'Notice',
       '!message' => 'Undefined variable: bananas',
-      '%function' => 'error_test_generate_warnings()',
+      '%function' => 'Drupal\error_test_generate_warnings()',
       '%file' => drupal_realpath('core/modules/simpletest/tests/error_test.module'),
     );
     $error_warning = array(
       '%type' => 'Warning',
       '!message' => 'Division by zero',
-      '%function' => 'error_test_generate_warnings()',
+      '%function' => 'Drupal\error_test_generate_warnings()',
       '%file' => drupal_realpath('core/modules/simpletest/tests/error_test.module'),
     );
     $error_user_notice = array(
       '%type' => 'User warning',
       '!message' => 'Drupal is awesome',
-      '%function' => 'error_test_generate_warnings()',
+      '%function' => 'Drupal\error_test_generate_warnings()',
       '%file' => drupal_realpath('core/modules/simpletest/tests/error_test.module'),
     );
 
@@ -71,14 +73,14 @@ class DrupalErrorHandlerUnitTest extends DrupalWebTestCase {
     $error_exception = array(
       '%type' => 'Exception',
       '!message' => 'Drupal is awesome',
-      '%function' => 'error_test_trigger_exception()',
+      '%function' => 'Drupal\error_test_trigger_exception()',
       '%line' => 57,
       '%file' => drupal_realpath('core/modules/simpletest/tests/error_test.module'),
     );
     $error_pdo_exception = array(
       '%type' => 'PDOException',
       '!message' => 'SELECT * FROM bananas_are_awesome',
-      '%function' => 'error_test_trigger_pdo_exception()',
+      '%function' => 'Drupal\error_test_trigger_pdo_exception()',
       '%line' => 65,
       '%file' => drupal_realpath('core/modules/simpletest/tests/error_test.module'),
     );
diff --git a/core/modules/simpletest/tests/error_test.module b/core/modules/simpletest/tests/error_test.module
index d062cb0..c2379ee 100644
--- a/core/modules/simpletest/tests/error_test.module
+++ b/core/modules/simpletest/tests/error_test.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, PDO;
 
 /**
  * Implements hook_menu().
diff --git a/core/modules/simpletest/tests/file.test b/core/modules/simpletest/tests/file.test
index a369a44..a40e02d 100644
--- a/core/modules/simpletest/tests/file.test
+++ b/core/modules/simpletest/tests/file.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use PDO, stdClass;
 
 /**
  *  @file
@@ -39,14 +41,14 @@ function file_test_file_scan_callback($filepath = NULL) {
  * Reset static variables used by file_test_file_scan_callback().
  */
 function file_test_file_scan_callback_reset() {
-  drupal_static_reset('file_test_file_scan_callback');
+  drupal_static_reset('Drupal\file_test_file_scan_callback');
 }
 
 /**
  * Base class for file tests that adds some additional file specific
  * assertions and helper functions.
  */
-class FileTestCase extends DrupalWebTestCase {
+class FileTestCase extends WebTestCase {
   /**
    * Check that two files have the same values for all fields other than the
    * timestamp.
@@ -216,7 +218,7 @@ class FileTestCase extends DrupalWebTestCase {
 
     $file = new stdClass();
     $file->uri = $filepath;
-    $file->filename = drupal_basename($file->uri);
+    $file->filename = basename($file->uri);
     $file->filemime = 'text/plain';
     $file->uid = 1;
     $file->timestamp = REQUEST_TIME;
@@ -224,7 +226,7 @@ class FileTestCase extends DrupalWebTestCase {
     $file->status = 0;
     // Write the record directly rather than calling file_save() so we don't
     // invoke the hooks.
-    $this->assertNotIdentical(drupal_write_record('file_managed', $file), FALSE, t('The file was added to the database.'), 'Create test file');
+    $this->assertNotIdentical(write_record('file_managed', $file), FALSE, t('The file was added to the database.'), 'Create test file');
 
     return $file;
   }
@@ -319,19 +321,19 @@ class FileSpaceUsedTest extends FileTestCase {
 
     // Create records for a couple of users with different sizes.
     $file = array('uid' => 2, 'uri' => 'public://example1.txt', 'filesize' => 50, 'status' => FILE_STATUS_PERMANENT);
-    drupal_write_record('file_managed', $file);
+    write_record('file_managed', $file);
     $file = array('uid' => 2, 'uri' => 'public://example2.txt', 'filesize' => 20, 'status' => FILE_STATUS_PERMANENT);
-    drupal_write_record('file_managed', $file);
+    write_record('file_managed', $file);
     $file = array('uid' => 3, 'uri' => 'public://example3.txt', 'filesize' => 100, 'status' => FILE_STATUS_PERMANENT);
-    drupal_write_record('file_managed', $file);
+    write_record('file_managed', $file);
     $file = array('uid' => 3, 'uri' => 'public://example4.txt', 'filesize' => 200, 'status' => FILE_STATUS_PERMANENT);
-    drupal_write_record('file_managed', $file);
+    write_record('file_managed', $file);
 
     // Now create some non-permanent files.
     $file = array('uid' => 2, 'uri' => 'public://example5.txt', 'filesize' => 1, 'status' => 0);
-    drupal_write_record('file_managed', $file);
+    write_record('file_managed', $file);
     $file = array('uid' => 3, 'uri' => 'public://example6.txt', 'filesize' => 3, 'status' => 0);
-    drupal_write_record('file_managed', $file);
+    write_record('file_managed', $file);
   }
 
   /**
@@ -360,7 +362,7 @@ class FileSpaceUsedTest extends FileTestCase {
 /**
  *  This will run tests against the file validation functions (file_validate_*).
  */
-class FileValidatorTest extends DrupalWebTestCase {
+class FileValidatorTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'File validator tests',
@@ -374,11 +376,11 @@ class FileValidatorTest extends DrupalWebTestCase {
 
     $this->image = new stdClass();
     $this->image->uri = 'core/misc/druplicon.png';
-    $this->image->filename = drupal_basename($this->image->uri);
+    $this->image->filename = basename($this->image->uri);
 
     $this->non_image = new stdClass();
     $this->non_image->uri = 'core/misc/jquery.js';
-    $this->non_image->filename = drupal_basename($this->non_image->uri);
+    $this->non_image->filename = basename($this->non_image->uri);
   }
 
   /**
@@ -482,7 +484,7 @@ class FileValidatorTest extends DrupalWebTestCase {
   function testFileValidateSize() {
     global $user;
     $original_user = $user;
-    drupal_save_session(FALSE);
+    save_session(FALSE);
 
     // Run these test as uid = 1.
     $user = user_load(1);
@@ -508,7 +510,7 @@ class FileValidatorTest extends DrupalWebTestCase {
     $this->assertEqual(count($errors), 2, t('Errors for both the file and their limit.'), 'File');
 
     $user = $original_user;
-    drupal_save_session(TRUE);
+    save_session(TRUE);
   }
 }
 
@@ -541,7 +543,7 @@ class FileUnmanagedSaveDataTest extends FileTestCase {
     // Provide a filename.
     $filepath = file_unmanaged_save_data($contents, 'public://asdf.txt', FILE_EXISTS_REPLACE);
     $this->assertTrue($filepath, t('Unnamed file saved correctly.'));
-    $this->assertEqual('asdf.txt', drupal_basename($filepath), t('File was named correctly.'));
+    $this->assertEqual('asdf.txt', basename($filepath), t('File was named correctly.'));
     $this->assertEqual($contents, file_get_contents($filepath), t('Contents of the file are correct.'));
     $this->assertFilePermissions($filepath, variable_get('file_chmod_file', 0664));
   }
@@ -668,7 +670,7 @@ class FileSaveUploadTest extends FileHookTestCase {
     $this->drupalPost('file-test/upload', $edit, t('Submit'));
     $this->assertResponse(200, t('Received a 200 response for posted test file.'));
     $this->assertRaw(t('You WIN!'));
-    $this->assertTrue(is_file('temporary://' . $dir . '/' . trim(drupal_basename($image3_realpath))));
+    $this->assertTrue(is_file('temporary://' . $dir . '/' . trim(basename($image3_realpath))));
 
     // Check that file_load_multiple() with no arguments returns FALSE.
     $this->assertFalse(file_load_multiple(), t('No files were loaded.'));
@@ -1052,7 +1054,7 @@ class FileScanDirectoryTest extends FileTestCase {
 
   function setUp() {
     parent::setUp();
-    $this->path = drupal_get_path('module', 'simpletest') . '/files';
+    $this->path = get_path('module', 'simpletest') . '/files';
   }
 
   /**
@@ -1146,10 +1148,10 @@ class FileScanDirectoryTest extends FileTestCase {
    * Check that the recurse option decends into subdirectories.
    */
   function testOptionRecurse() {
-    $files = file_scan_directory(drupal_get_path('module', 'simpletest'), '/^javascript-/', array('recurse' => FALSE));
+    $files = file_scan_directory(get_path('module', 'simpletest'), '/^javascript-/', array('recurse' => FALSE));
     $this->assertTrue(empty($files), t("Without recursion couldn't find javascript files."));
 
-    $files = file_scan_directory(drupal_get_path('module', 'simpletest'), '/^javascript-/', array('recurse' => TRUE));
+    $files = file_scan_directory(get_path('module', 'simpletest'), '/^javascript-/', array('recurse' => TRUE));
     $this->assertEqual(2, count($files), t('With recursion we found the expected javascript files.'));
   }
 
@@ -2204,7 +2206,7 @@ class FileSaveDataTest extends FileHookTestCase {
     $this->assertTrue($result, t('Unnamed file saved correctly.'));
 
     $this->assertEqual(file_default_scheme(), file_uri_scheme($result->uri), t("File was placed in Drupal's files directory."));
-    $this->assertEqual($result->filename, drupal_basename($result->uri), t("Filename was set to the file's basename."));
+    $this->assertEqual($result->filename, basename($result->uri), t("Filename was set to the file's basename."));
     $this->assertEqual($contents, file_get_contents($result->uri), t('Contents of the file are correct.'));
     $this->assertEqual($result->filemime, 'application/octet-stream', t('A MIME type was set.'));
     $this->assertEqual($result->status, FILE_STATUS_PERMANENT, t("The file's status was set to permanent."));
@@ -2229,7 +2231,7 @@ class FileSaveDataTest extends FileHookTestCase {
     $this->assertTrue($result, t('Unnamed file saved correctly.'));
 
     $this->assertEqual('public', file_uri_scheme($result->uri), t("File was placed in Drupal's files directory."));
-    $this->assertEqual($filename, drupal_basename($result->uri), t('File was named correctly.'));
+    $this->assertEqual($filename, basename($result->uri), t('File was named correctly.'));
     $this->assertEqual($contents, file_get_contents($result->uri), t('Contents of the file are correct.'));
     $this->assertEqual($result->filemime, 'text/plain', t('A MIME type was set.'));
     $this->assertEqual($result->status, FILE_STATUS_PERMANENT, t("The file's status was set to permanent."));
@@ -2560,7 +2562,7 @@ class FileNameMungingTest extends FileTestCase {
     // Disable insecure uploads.
     variable_set('allow_insecure_uploads', 0);
     $munged_name = file_munge_filename($this->name, '', TRUE);
-    $messages = drupal_get_messages();
+    $messages = get_messages();
     $this->assertTrue(in_array(t('For security reasons, your upload has been renamed to %filename.', array('%filename' => $munged_name)), $messages['status']), t('Alert properly set when a file is renamed.'));
     $this->assertNotEqual($munged_name, $this->name, t('The new filename (%munged) has been modified from the original (%original)', array('%munged' => $munged_name, '%original' => $this->name)));
   }
@@ -2597,7 +2599,7 @@ class FileNameMungingTest extends FileTestCase {
 /**
  * Tests for file_get_mimetype().
  */
-class FileMimeTypeTest extends DrupalWebTestCase {
+class FileMimeTypeTest extends WebTestCase {
   function setUp() {
     parent::setUp('file_test');
   }
@@ -2682,10 +2684,10 @@ class FileMimeTypeTest extends DrupalWebTestCase {
 /**
  * Tests stream wrapper functions.
  */
-class StreamWrapperTest extends DrupalWebTestCase {
+class StreamWrapperTest extends WebTestCase {
 
   protected $scheme = 'dummy';
-  protected $classname = 'DrupalDummyStreamWrapper';
+  protected $classname = 'Drupal\DummyStreamWrapper';
 
   public static function getInfo() {
     return array(
@@ -2697,7 +2699,7 @@ class StreamWrapperTest extends DrupalWebTestCase {
 
   function setUp() {
     parent::setUp('file_test');
-    drupal_static_reset('file_get_stream_wrappers');
+    drupal_static_reset('Drupal\file_get_stream_wrappers');
   }
 
   function tearDown() {
@@ -2712,7 +2714,7 @@ class StreamWrapperTest extends DrupalWebTestCase {
     // Check the dummy scheme.
     $this->assertEqual($this->classname, file_stream_wrapper_get_class($this->scheme), t('Got correct class name for dummy scheme.'));
     // Check core's scheme.
-    $this->assertEqual('DrupalPublicStreamWrapper', file_stream_wrapper_get_class('public'), t('Got correct class name for public scheme.'));
+    $this->assertEqual('Drupal\PublicStreamWrapper', file_stream_wrapper_get_class('public'), t('Got correct class name for public scheme.'));
   }
 
   /**
@@ -2723,7 +2725,7 @@ class StreamWrapperTest extends DrupalWebTestCase {
     $this->assertEqual($this->classname, get_class($instance), t('Got correct class type for dummy scheme.'));
 
     $instance = file_stream_wrapper_get_instance_by_scheme('public');
-    $this->assertEqual('DrupalPublicStreamWrapper', get_class($instance), t('Got correct class type for public scheme.'));
+    $this->assertEqual('Drupal\PublicStreamWrapper', get_class($instance), t('Got correct class type for public scheme.'));
   }
 
   /**
@@ -2734,13 +2736,13 @@ class StreamWrapperTest extends DrupalWebTestCase {
     $this->assertEqual($this->classname, get_class($instance), t('Got correct class type for dummy URI.'));
 
     $instance = file_stream_wrapper_get_instance_by_uri('public://foo');
-    $this->assertEqual('DrupalPublicStreamWrapper', get_class($instance), t('Got correct class type for public URI.'));
+    $this->assertEqual('Drupal\PublicStreamWrapper', get_class($instance), t('Got correct class type for public URI.'));
 
     // Test file_uri_target().
     $this->assertEqual(file_uri_target('public://foo/bar.txt'), 'foo/bar.txt', t('Got a valid stream target from public://foo/bar.txt.'));
     $this->assertFalse(file_uri_target('foo/bar.txt'), t('foo/bar.txt is not a valid stream.'));
 
-    // Test file_build_uri() and DrupalLocalStreamWrapper::getDirectoryPath().
+    // Test file_build_uri() and LocalStreamWrapper::getDirectoryPath().
     $this->assertEqual(file_build_uri('foo/bar.txt'), 'public://foo/bar.txt', t('Expected scheme was added.'));
     $this->assertEqual(file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath(), variable_get('file_public_path'), t('Expected default directory path was returned.'));
     $this->assertEqual(file_stream_wrapper_get_instance_by_scheme('temporary')->getDirectoryPath(), variable_get('file_temporary_path'), t('Expected temporary directory path was returned.'));
diff --git a/core/modules/simpletest/tests/file_test.module b/core/modules/simpletest/tests/file_test.module
index 6fcda95..6e0c63d 100644
--- a/core/modules/simpletest/tests/file_test.module
+++ b/core/modules/simpletest/tests/file_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -19,7 +20,7 @@ const FILE_URL_TEST_CDN_2 = 'http://cdn2.example.com';
 function file_test_menu() {
   $items['file-test/upload'] = array(
     'title' => 'Upload test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('_file_test_form'),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
@@ -34,12 +35,12 @@ function file_test_stream_wrappers() {
   return array(
     'dummy' => array(
       'name' => t('Dummy files'),
-      'class' => 'DrupalDummyStreamWrapper',
+      'class' => 'DummyStreamWrapper',
       'description' => t('Dummy wrapper for simpletest.'),
     ),
     'dummy-remote' => array(
       'name' => t('Dummy files (remote)'),
-      'class' => 'DrupalDummyRemoteStreamWrapper',
+      'class' => 'DummyRemoteStreamWrapper',
       'description' => t('Dummy wrapper for simpletest (remote).'),
     ),
   );
@@ -124,13 +125,13 @@ function _file_test_form_submit(&$form, &$form_state) {
   $file = file_save_upload('file_test_upload', $validators, $destination, $form_state['values']['file_test_replace']);
   if ($file) {
     $form_state['values']['file_test_upload'] = $file;
-    drupal_set_message(t('File @filepath was uploaded.', array('@filepath' => $file->uri)));
-    drupal_set_message(t('File name is @filename.', array('@filename' => $file->filename)));
-    drupal_set_message(t('File MIME type is @mimetype.', array('@mimetype' => $file->filemime)));
-    drupal_set_message(t('You WIN!'));
+    set_message(t('File @filepath was uploaded.', array('@filepath' => $file->uri)));
+    set_message(t('File name is @filename.', array('@filename' => $file->filename)));
+    set_message(t('File MIME type is @mimetype.', array('@mimetype' => $file->filemime)));
+    set_message(t('You WIN!'));
   }
   elseif ($file === FALSE) {
-    drupal_set_message(t('Epic upload FAIL!'), 'error');
+    set_message(t('Epic upload FAIL!'), 'error');
   }
 }
 
@@ -423,7 +424,7 @@ function file_test_file_mimetype_mapping_alter(&$mapping) {
  *
  * Dummy stream wrapper implementation (dummy://).
  */
-class DrupalDummyStreamWrapper extends DrupalLocalStreamWrapper {
+class DummyStreamWrapper extends LocalStreamWrapper {
   function getDirectoryPath() {
     return variable_get('stream_public_path', 'sites/default/files');
   }
@@ -454,7 +455,7 @@ class DrupalDummyStreamWrapper extends DrupalLocalStreamWrapper {
  *
  * Basically just the public scheme but not returning a local file for realpath.
  */
-class DrupalDummyRemoteStreamWrapper extends DrupalPublicStreamWrapper {
+class DummyRemoteStreamWrapper extends PublicStreamWrapper {
   function realpath() {
     return FALSE;
   }
diff --git a/core/modules/simpletest/tests/filetransfer.test b/core/modules/simpletest/tests/filetransfer.test
index 905d23c..3a8feb3 100644
--- a/core/modules/simpletest/tests/filetransfer.test
+++ b/core/modules/simpletest/tests/filetransfer.test
@@ -1,7 +1,9 @@
 <?php
+namespace Drupal;
+use Exception;
 
 
-class FileTranferTest extends DrupalWebTestCase {
+class FileTranferTest extends WebTestCase {
   protected $hostname = 'localhost';
   protected $username = 'drupal';
   protected $password = 'password';
@@ -17,7 +19,7 @@ class FileTranferTest extends DrupalWebTestCase {
 
   function setUp() {
     parent::setUp();
-    $this->testConnection = TestFileTransfer::factory(DRUPAL_ROOT, array('hostname' => $this->hostname, 'username' => $this->username, 'password' => $this->password, 'port' => $this->port));
+    $this->testConnection = TestFileTransfer::factory(ROOT, array('hostname' => $this->hostname, 'username' => $this->username, 'password' => $this->password, 'port' => $this->port));
   }
 
   function _getFakeModuleFiles() {
@@ -79,7 +81,7 @@ class FileTranferTest extends DrupalWebTestCase {
 
     $gotit = TRUE;
     try {
-      $this->testConnection->copyDirectory($source, DRUPAL_ROOT . '/'. variable_get('file_public_path', conf_path() . '/files'));
+      $this->testConnection->copyDirectory($source, ROOT . '/'. variable_get('file_public_path', conf_path() . '/files'));
     }
     catch (FileTransferException $e) {
       $gotit = FALSE;
diff --git a/core/modules/simpletest/tests/filter_test.module b/core/modules/simpletest/tests/filter_test.module
index 2cebc70..a675b53 100644
--- a/core/modules/simpletest/tests/filter_test.module
+++ b/core/modules/simpletest/tests/filter_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -9,21 +10,21 @@
  * Implements hook_filter_format_insert().
  */
 function filter_test_filter_format_insert($format) {
-  drupal_set_message('hook_filter_format_insert invoked.');
+  set_message('hook_filter_format_insert invoked.');
 }
 
 /**
  * Implements hook_filter_format_update().
  */
 function filter_test_filter_format_update($format) {
-  drupal_set_message('hook_filter_format_update invoked.');
+  set_message('hook_filter_format_update invoked.');
 }
 
 /**
  * Implements hook_filter_format_disable().
  */
 function filter_test_filter_format_disable($format) {
-  drupal_set_message('hook_filter_format_disable invoked.');
+  set_message('hook_filter_format_disable invoked.');
 }
 
 /**
diff --git a/core/modules/simpletest/tests/form.test b/core/modules/simpletest/tests/form.test
index 784da88..6276cde 100644
--- a/core/modules/simpletest/tests/form.test
+++ b/core/modules/simpletest/tests/form.test
@@ -1,11 +1,12 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
  * Unit tests for the Drupal Form API.
  */
 
-class FormsTestCase extends DrupalWebTestCase {
+class FormsTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -85,8 +86,8 @@ class FormsTestCase extends DrupalWebTestCase {
           $form_state['input'][$element] = $empty;
           $form_state['input']['form_id'] = $form_id;
           $form_state['method'] = 'post';
-          drupal_prepare_form($form_id, $form, $form_state);
-          drupal_process_form($form_id, $form, $form_state);
+          prepare_form($form_id, $form, $form_state);
+          process_form($form_id, $form, $form_state);
           $errors = form_get_errors();
           // Form elements of type 'radios' throw all sorts of PHP notices
           // when you try to render them like this, so we ignore those for
@@ -121,7 +122,7 @@ class FormsTestCase extends DrupalWebTestCase {
       }
     }
     // Clear the expected form error messages so they don't appear as exceptions.
-    drupal_get_messages();
+    get_messages();
   }
 
   /**
@@ -374,7 +375,7 @@ class FormsTestCase extends DrupalWebTestCase {
 /**
  * Tests building and processing of core form elements.
  */
-class FormElementTestCase extends DrupalWebTestCase {
+class FormElementTestCase extends WebTestCase {
   protected $profile = 'testing';
 
   public static function getInfo() {
@@ -458,7 +459,7 @@ class FormElementTestCase extends DrupalWebTestCase {
 /**
  * Test form alter hooks.
  */
-class FormAlterTestCase extends DrupalWebTestCase {
+class FormAlterTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Form alter hooks',
@@ -492,7 +493,7 @@ class FormAlterTestCase extends DrupalWebTestCase {
 /**
  * Test form validation handlers.
  */
-class FormValidationTestCase extends DrupalWebTestCase {
+class FormValidationTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Form validation handlers',
@@ -589,7 +590,7 @@ class FormValidationTestCase extends DrupalWebTestCase {
 /**
  * Test form element labels, required markers and associated output.
  */
-class FormsElementsLabelsTestCase extends DrupalWebTestCase {
+class FormsElementsLabelsTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -670,7 +671,7 @@ class FormsElementsLabelsTestCase extends DrupalWebTestCase {
 /**
  * Test the tableselect form element for expected behavior.
  */
-class FormsElementsTableSelectFunctionalTest extends DrupalWebTestCase {
+class FormsElementsTableSelectFunctionalTest extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -851,14 +852,14 @@ class FormsElementsTableSelectFunctionalTest extends DrupalWebTestCase {
     $form_state['input'] = $edit;
     $form_state['input']['form_id'] = $form_id;
 
-    drupal_prepare_form($form_id, $form, $form_state);
+    prepare_form($form_id, $form, $form_state);
 
-    drupal_process_form($form_id, $form, $form_state);
+    process_form($form_id, $form, $form_state);
 
     $errors = form_get_errors();
 
     // Clear errors and messages.
-    drupal_get_messages();
+    get_messages();
     form_clear_error();
 
     // Return the processed form together with form_state and errors
@@ -871,7 +872,7 @@ class FormsElementsTableSelectFunctionalTest extends DrupalWebTestCase {
 /**
  * Test the vertical_tabs form element for expected behavior.
  */
-class FormsElementsVerticalTabsFunctionalTest extends DrupalWebTestCase {
+class FormsElementsVerticalTabsFunctionalTest extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -907,7 +908,7 @@ class FormsElementsVerticalTabsFunctionalTest extends DrupalWebTestCase {
  * when a validation error occurs, it makes sure that changed form element
  * values aren't lost due to a wrong form rebuild.
  */
-class FormsFormStorageTestCase extends DrupalWebTestCase {
+class FormsFormStorageTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1051,7 +1052,7 @@ class FormsFormStorageTestCase extends DrupalWebTestCase {
 /**
  * Test wrapper form callbacks.
  */
-class FormsFormWrapperTestCase extends DrupalWebTestCase {
+class FormsFormWrapperTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Form wrapper callback',
@@ -1077,7 +1078,7 @@ class FormsFormWrapperTestCase extends DrupalWebTestCase {
 /**
  * Test $form_state clearance.
  */
-class FormStateValuesCleanTestCase extends DrupalWebTestCase {
+class FormStateValuesCleanTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Form state values clearance',
@@ -1125,7 +1126,7 @@ class FormStateValuesCleanTestCase extends DrupalWebTestCase {
 /**
  * Tests $form_state clearance with form elements having buttons.
  */
-class FormStateValuesCleanAdvancedTestCase extends DrupalWebTestCase {
+class FormStateValuesCleanAdvancedTestCase extends WebTestCase {
   /**
    * An image file path for uploading.
    */
@@ -1172,11 +1173,11 @@ class FormStateValuesCleanAdvancedTestCase extends DrupalWebTestCase {
  *
  * @todo Add tests for other aspects of form rebuilding.
  */
-class FormsRebuildTestCase extends DrupalWebTestCase {
+class FormsRebuildTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Form rebuilding',
-      'description' => 'Tests functionality of drupal_rebuild_form().',
+      'description' => 'Tests functionality of rebuild_form().',
       'group' => 'Form API',
     );
   }
@@ -1264,7 +1265,7 @@ class FormsRebuildTestCase extends DrupalWebTestCase {
 /**
  * Test the programmatic form submission behavior.
  */
-class FormsProgrammaticTestCase extends DrupalWebTestCase {
+class FormsProgrammaticTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1327,7 +1328,7 @@ class FormsProgrammaticTestCase extends DrupalWebTestCase {
   private function submitForm($values, $valid_input) {
     // Programmatically submit the given values.
     $form_state = array('values' => $values);
-    drupal_form_submit('form_test_programmatic_form', $form_state);
+    form_submit('form_test_programmatic_form', $form_state);
 
     // Check that the form returns an error when expected, and vice versa.
     $errors = form_get_errors();
@@ -1353,7 +1354,7 @@ class FormsProgrammaticTestCase extends DrupalWebTestCase {
 /**
  * Test that FAPI correctly determines $form_state['triggering_element'].
  */
-class FormsTriggeringElementTestCase extends DrupalWebTestCase {
+class FormsTriggeringElementTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1451,7 +1452,7 @@ class FormsTriggeringElementTestCase extends DrupalWebTestCase {
 /**
  * Tests rebuilding of arbitrary forms by altering them.
  */
-class FormsArbitraryRebuildTestCase extends DrupalWebTestCase {
+class FormsArbitraryRebuildTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Rebuild arbitrary forms',
@@ -1517,7 +1518,7 @@ class FormsArbitraryRebuildTestCase extends DrupalWebTestCase {
 /**
  * Tests form API file inclusion.
  */
-class FormsFileInclusionTestCase extends DrupalWebTestCase {
+class FormsFileInclusionTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1551,7 +1552,7 @@ class FormsFileInclusionTestCase extends DrupalWebTestCase {
 /**
  * Tests checkbox element.
  */
-class FormCheckboxTestCase extends DrupalWebTestCase {
+class FormCheckboxTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1573,7 +1574,7 @@ class FormCheckboxTestCase extends DrupalWebTestCase {
       // #return_value, with the exception of integer 0, which is not supported.
       // @see form_process_checkbox().
       foreach (array('0', '', 1, '1', 'foobar', '1foobar') as $return_value) {
-        $form_array = drupal_get_form('form_test_checkbox_type_juggling', $default_value, $return_value);
+        $form_array = get_form('form_test_checkbox_type_juggling', $default_value, $return_value);
         $form = drupal_render($form_array);
         if ($default_value === TRUE) {
           $checked = TRUE;
diff --git a/core/modules/simpletest/tests/form_test.file.inc b/core/modules/simpletest/tests/form_test.file.inc
index f9197ea..fceacfb 100644
--- a/core/modules/simpletest/tests/form_test.file.inc
+++ b/core/modules/simpletest/tests/form_test.file.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -12,7 +13,7 @@
 function form_test_load_include_menu($form, &$form_state) {
   // Submit the form via Ajax. That way the FAPI has to care about including
   // the file specified in hook_menu().
-  $ajax_wrapper_id = drupal_html_id('form-test-load-include-menu-ajax-wrapper');
+  $ajax_wrapper_id = html_id('form-test-load-include-menu-ajax-wrapper');
   $form['ajax_wrapper'] = array(
     '#markup' => '<div id="' . $ajax_wrapper_id . '"></div>',
   );
@@ -33,7 +34,7 @@ function form_test_load_include_menu($form, &$form_state) {
  * Submit callback for the form API file inclusion test forms.
  */
 function form_test_load_include_submit($form, $form_state) {
-  drupal_set_message('Submit callback called.');
+  set_message('Submit callback called.');
 }
 
 /**
diff --git a/core/modules/simpletest/tests/form_test.module b/core/modules/simpletest/tests/form_test.module
index e1e2435..0d6703a 100644
--- a/core/modules/simpletest/tests/form_test.module
+++ b/core/modules/simpletest/tests/form_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -11,21 +12,21 @@
 function form_test_menu() {
   $items['form-test/alter'] = array(
     'title' => 'Form altering test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('form_test_alter_form'),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );
   $items['form-test/validate'] = array(
     'title' => 'Form validation handlers test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('form_test_validate_form'),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );
   $items['form-test/limit-validation-errors'] = array(
     'title' => 'Form validation with some error suppression',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('form_test_limit_validation_errors_form'),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
@@ -33,28 +34,28 @@ function form_test_menu() {
 
   $items['form_test/tableselect/multiple-true'] = array(
     'title' => 'Tableselect checkboxes test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('_form_test_tableselect_multiple_true_form'),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );
   $items['form_test/tableselect/multiple-false'] = array(
     'title' => 'Tableselect radio button test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('_form_test_tableselect_multiple_false_form'),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );
   $items['form_test/tableselect/empty-text'] = array(
     'title' => 'Tableselect empty text test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('_form_test_tableselect_empty_form'),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );
   $items['form_test/tableselect/advanced-select'] = array(
     'title' => 'Tableselect js_select tests',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('_form_test_tableselect_js_select_form'),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
@@ -62,7 +63,7 @@ function form_test_menu() {
 
   $items['form_test/vertical-tabs'] = array(
     'title' => 'Vertical tabs tests',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('_form_test_vertical_tabs_form'),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
@@ -70,7 +71,7 @@ function form_test_menu() {
 
   $items['form_test/form-storage'] = array(
     'title' => 'Form storage test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('form_test_storage_form'),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
@@ -86,7 +87,7 @@ function form_test_menu() {
 
   $items['form_test/form-state-values-clean'] = array(
     'title' => 'Form state values clearance test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('form_test_form_state_values_clean_form'),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
@@ -94,7 +95,7 @@ function form_test_menu() {
 
   $items['form_test/form-state-values-clean-advanced'] = array(
     'title' => 'Form state values clearance advanced test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('form_test_form_state_values_clean_advanced_form'),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
@@ -102,33 +103,33 @@ function form_test_menu() {
 
   $items['form-test/checkbox'] = array(
     'title' => t('Form test'),
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('_form_test_checkbox'),
     'access callback' => TRUE,
     'type' => MENU_CALLBACK,
   );
   $items['form-test/select'] = array(
     'title' => t('Select'),
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('form_test_select'),
     'access callback' => TRUE,
   );
   $items['form-test/placeholder-text'] = array(
     'title' => 'Placeholder',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('form_test_placeholder_test'),
     'access callback' => TRUE,
   );
   $items['form-test/checkboxes-radios'] = array(
     'title' => t('Checkboxes, Radios'),
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('form_test_checkboxes_radios'),
     'access callback' => TRUE,
   );
 
   $items['form-test/disabled-elements'] = array(
     'title' => t('Form test'),
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('_form_test_disabled_elements'),
     'access callback' => TRUE,
     'type' => MENU_CALLBACK,
@@ -136,7 +137,7 @@ function form_test_menu() {
 
   $items['form-test/input-forgery'] = array(
     'title' => t('Form test'),
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('_form_test_input_forgery'),
     'access callback' => TRUE,
     'type' => MENU_CALLBACK,
@@ -144,7 +145,7 @@ function form_test_menu() {
 
   $items['form-test/form-rebuild-preserve-values'] = array(
     'title' => 'Form values preservation during rebuild test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('form_test_form_rebuild_preserve_values_form'),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
@@ -152,7 +153,7 @@ function form_test_menu() {
 
   $items['form_test/form-labels'] = array(
     'title' => 'Form label test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('form_label_test_form'),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
@@ -160,7 +161,7 @@ function form_test_menu() {
 
   $items['form-test/state-persist'] = array(
     'title' => 'Form state persistence without storage',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('form_test_state_persist'),
     'access callback' => TRUE,
     'type' => MENU_CALLBACK,
@@ -168,7 +169,7 @@ function form_test_menu() {
 
   $items['form-test/clicked-button'] = array(
     'title' => 'Clicked button test',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('form_test_clicked_button'),
     'access callback' => TRUE,
     'type' => MENU_CALLBACK,
@@ -180,7 +181,7 @@ function form_test_menu() {
       'page callback' => 'form_test_two_instances',
       'access callback' => 'node_access',
       'access arguments' => array('create', 'page'),
-      'file path' => drupal_get_path('module', 'node'),
+      'file path' => get_path('module', 'node'),
       'file' => 'node.pages.inc',
       'type' => MENU_CALLBACK,
     );
@@ -188,7 +189,7 @@ function form_test_menu() {
 
   $items['form-test/load-include-menu'] = array(
     'title' => 'FAPI test loading includes',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('form_test_load_include_menu'),
     'access callback' => TRUE,
     'file' => 'form_test.file.inc',
@@ -197,14 +198,14 @@ function form_test_menu() {
 
   $items['form-test/load-include-custom'] = array(
     'title' => 'FAPI test loading includes',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('form_test_load_include_custom'),
     'access callback' => TRUE,
     'type' => MENU_CALLBACK,
   );
   $items['form-test/checkboxes-zero'] = array(
     'title' => 'FAPI test involving checkboxes and zero',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('form_test_checkboxes_zero'),
     'access callback' => TRUE,
     'type' => MENU_CALLBACK,
@@ -217,7 +218,7 @@ function form_test_menu() {
  * Form submit handler to return form values as JSON.
  */
 function _form_test_submit_values_json($form, &$form_state) {
-  drupal_json_output($form_state['values']);
+  json_output($form_state['values']);
   drupal_exit();
 }
 
@@ -235,7 +236,7 @@ function form_test_alter_form($form, &$form_state) {
  * Implements hook_form_FORM_ID_alter() on behalf of block.module.
  */
 function block_form_form_test_alter_form_alter(&$form, &$form_state) {
-  drupal_set_message('block_form_form_test_alter_form_alter() executed.');
+  set_message('block_form_form_test_alter_form_alter() executed.');
 }
 
 /**
@@ -243,7 +244,7 @@ function block_form_form_test_alter_form_alter(&$form, &$form_state) {
  */
 function form_test_form_alter(&$form, &$form_state, $form_id) {
   if ($form_id == 'form_test_alter_form') {
-    drupal_set_message('form_test_form_alter() executed.');
+    set_message('form_test_form_alter() executed.');
   }
 }
 
@@ -251,18 +252,18 @@ function form_test_form_alter(&$form, &$form_state, $form_id) {
  * Implements hook_form_FORM_ID_alter().
  */
 function form_test_form_form_test_alter_form_alter(&$form, &$form_state) {
-  drupal_set_message('form_test_form_form_test_alter_form_alter() executed.');
+  set_message('form_test_form_form_test_alter_form_alter() executed.');
 }
 
 /**
  * Implements hook_form_FORM_ID_alter() on behalf of system.module.
  */
 function system_form_form_test_alter_form_alter(&$form, &$form_state) {
-  drupal_set_message('system_form_form_test_alter_form_alter() executed.');
+  set_message('system_form_form_test_alter_form_alter() executed.');
 }
 
 /**
- * Form builder for testing drupal_validate_form().
+ * Form builder for testing validate_form().
  *
  * Serves for testing form processing and alterations by form validation
  * handlers, especially for the case of a validation error:
@@ -321,7 +322,7 @@ function form_test_element_validate_name(&$element, &$form_state) {
 
   if ($triggered) {
     // Output the element's value from $form_state.
-    drupal_set_message(t('@label value: @value', array('@label' => $element['#title'], '@value' => $form_state['values']['name'])));
+    set_message(t('@label value: @value', array('@label' => $element['#title'], '@value' => $form_state['values']['name'])));
 
     // Trigger a form validation error to see our changes.
     form_set_error('');
@@ -338,7 +339,7 @@ function form_test_validate_form_validate(&$form, &$form_state) {
     // Alter the submitted value in $form_state.
     form_set_value($form['name'], 'value changed by form_set_value() in #validate', $form_state);
     // Output the element's value from $form_state.
-    drupal_set_message(t('@label value: @value', array('@label' => $form['name']['#title'], '@value' => $form_state['values']['name'])));
+    set_message(t('@label value: @value', array('@label' => $form['name']['#title'], '@value' => $form_state['values']['name'])));
 
     // Trigger a form validation error to see our changes.
     form_set_error('');
@@ -424,7 +425,7 @@ function form_test_limit_validation_errors_form_partial_submit($form, $form_stat
   // The title has not been validated, thus its value - in case of the test case
   // an empty string - may not be set.
   if (!isset($form_state['values']['title']) && isset($form_state['values']['test'])) {
-    drupal_set_message('Only validated values appear in the form values.');
+    set_message('Only validated values appear in the form values.');
   }
 }
 
@@ -508,7 +509,7 @@ function _form_test_tableselect_multiple_true_form($form, $form_state) {
 function _form_test_tableselect_multiple_true_form_submit($form, &$form_state) {
   $selected = $form_state['values']['tableselect'];
   foreach ($selected as $key => $value) {
-    drupal_set_message(t('Submitted: @key = @value', array('@key' => $key, '@value' => $value)));
+    set_message(t('Submitted: @key = @value', array('@key' => $key, '@value' => $value)));
   }
 }
 
@@ -523,7 +524,7 @@ function _form_test_tableselect_multiple_false_form($form, $form_state) {
  * Process the tableselect #multiple = FALSE submitted values.
  */
 function _form_test_tableselect_multiple_false_form_submit($form, &$form_state) {
-  drupal_set_message(t('Submitted: @value', array('@value' => $form_state['values']['tableselect'])));
+  set_message(t('Submitted: @value', array('@value' => $form_state['values']['tableselect'])));
 }
 
 /**
@@ -617,7 +618,7 @@ function form_test_storage_form($form, &$form_state) {
   }
   // Count how often the form is constructed.
   $_SESSION['constructions']++;
-  drupal_set_message("Form constructions: " . $_SESSION['constructions']);
+  set_message("Form constructions: " . $_SESSION['constructions']);
 
   $form['title'] = array(
     '#type' => 'textfield',
@@ -683,10 +684,10 @@ function form_storage_test_form_continue_submit($form, &$form_state) {
  * Form submit handler to finish multi-step form.
  */
 function form_test_storage_form_submit($form, &$form_state) {
-  drupal_set_message("Title: " . check_plain($form_state['values']['title']));
-  drupal_set_message("Form constructions: " . $_SESSION['constructions']);
+  set_message("Title: " . check_plain($form_state['values']['title']));
+  set_message("Form constructions: " . $_SESSION['constructions']);
   if (isset($form_state['storage']['thing']['changed'])) {
-    drupal_set_message("The thing has been changed.");
+    set_message("The thing has been changed.");
   }
   $form_state['redirect'] = 'node';
 }
@@ -768,7 +769,7 @@ function form_test_wrapper_callback($form_id) {
     'build_info' => array('args' => array()),
     'wrapper_callback' => 'form_test_wrapper_callback_wrapper',
   );
-  return drupal_build_form($form_id, $form_state);
+  return build_form($form_id, $form_state);
 }
 
 /**
@@ -808,7 +809,7 @@ function form_test_form_state_values_clean_form($form, &$form_state) {
  */
 function form_test_form_state_values_clean_form_submit($form, &$form_state) {
   form_state_values_clean($form_state);
-  drupal_json_output($form_state['values']);
+  json_output($form_state['values']);
   exit;
 }
 
@@ -910,7 +911,7 @@ function _form_test_checkbox($form, &$form_state) {
  * Return the form values via JSON.
  */
 function _form_test_checkbox_submit($form, &$form_state) {
-  drupal_json_output($form_state['values']);
+  json_output($form_state['values']);
   exit();
 }
 
@@ -920,7 +921,7 @@ function _form_test_checkbox_submit($form, &$form_state) {
 function form_test_select($form, &$form_state) {
   $base = array(
     '#type' => 'select',
-    '#options' => drupal_map_assoc(array('one', 'two', 'three')),
+    '#options' => map_assoc(array('one', 'two', 'three')),
   );
 
   $form['select'] = $base + array(
@@ -1019,7 +1020,7 @@ function form_test_select($form, &$form_state) {
  * Form submit handler for form_test_select().
  */
 function form_test_select_submit($form, &$form_state) {
-  drupal_json_output($form_state['values']);
+  json_output($form_state['values']);
   exit();
 }
 
@@ -1275,7 +1276,7 @@ function _form_test_disabled_elements($form, &$form_state) {
  * Return the form values via JSON.
  */
 function _form_test_disabled_elements_submit($form, &$form_state) {
-  drupal_json_output($form_state['values']);
+  json_output($form_state['values']);
   exit();
 }
 
@@ -1304,7 +1305,7 @@ function _form_test_input_forgery($form, &$form_state) {
  * Return the form values via JSON.
  */
 function _form_test_input_forgery_submit($form, &$form_state) {
-  drupal_json_output($form_state['values']);
+  json_output($form_state['values']);
   exit();
 }
 
@@ -1383,7 +1384,7 @@ function form_test_form_rebuild_preserve_values_form_add_more($form, &$form_stat
  */
 function form_test_form_rebuild_preserve_values_form_submit($form, &$form_state) {
   // Finish the workflow. Do not rebuild.
-  drupal_set_message(t('Form values: %values', array('%values' => var_export($form_state['values'], TRUE))));
+  set_message(t('Form values: %values', array('%values' => var_export($form_state['values'], TRUE))));
 }
 
 /**
@@ -1411,7 +1412,7 @@ function form_test_state_persist($form, &$form_state) {
  * @see form_test_state_persist()
  */
 function form_test_state_persist_submit($form, &$form_state) {
-  drupal_set_message($form_state['value']);
+  set_message($form_state['value']);
   $form_state['rebuild'] = TRUE;
 }
 
@@ -1570,10 +1571,10 @@ function form_test_clicked_button($form, &$form_state) {
  */
 function form_test_clicked_button_validate($form, &$form_state) {
   if (isset($form_state['triggering_element'])) {
-    drupal_set_message(t('The clicked button is %name.', array('%name' => $form_state['triggering_element']['#name'])));
+    set_message(t('The clicked button is %name.', array('%name' => $form_state['triggering_element']['#name'])));
   }
   else {
-    drupal_set_message('There is no clicked button.');
+    set_message('There is no clicked button.');
   }
 }
 
@@ -1581,7 +1582,7 @@ function form_test_clicked_button_validate($form, &$form_state) {
  * Form submit handler for the form_test_clicked_button() form.
  */
 function form_test_clicked_button_submit($form, &$form_state) {
-  drupal_set_message('Submit handler for form_test_clicked_button executed.');
+  set_message('Submit handler for form_test_clicked_button executed.');
 }
 
 /**
@@ -1604,7 +1605,7 @@ function form_test_form_user_register_form_alter(&$form, &$form_state) {
  * Submit callback that just lets the form rebuild.
  */
 function form_test_user_register_form_rebuild($form, &$form_state) {
-  drupal_set_message('Form rebuilt.');
+  set_message('Form rebuilt.');
   $form_state['rebuild'] = TRUE;
 }
 
@@ -1620,8 +1621,8 @@ function form_test_two_instances() {
     'language' => LANGUAGE_NONE,
   );
   $node2 = clone($node1);
-  $return['node_form_1'] = drupal_get_form('page_node_form', $node1);
-  $return['node_form_2'] = drupal_get_form('page_node_form', $node2);
+  $return['node_form_1'] = get_form('page_node_form', $node1);
+  $return['node_form_2'] = get_form('page_node_form', $node2);
   return $return;
 }
 
diff --git a/core/modules/simpletest/tests/graph.test b/core/modules/simpletest/tests/graph.test
index e60cd39..a4f1acc 100644
--- a/core/modules/simpletest/tests/graph.test
+++ b/core/modules/simpletest/tests/graph.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -8,7 +9,7 @@
 /**
  * Unit tests for the graph handling features.
  */
-class GraphUnitTest extends DrupalUnitTestCase {
+class GraphUnitTest extends UnitTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Graph',
@@ -18,7 +19,7 @@ class GraphUnitTest extends DrupalUnitTestCase {
   }
 
   function setUp() {
-    require_once DRUPAL_ROOT . '/core/includes/graph.inc';
+    require_once ROOT . '/core/includes/graph.inc';
     parent::setUp();
   }
 
@@ -42,7 +43,7 @@ class GraphUnitTest extends DrupalUnitTestCase {
       8 => array(9),
       9 => array(),
     ));
-    drupal_depth_first_search($graph);
+    depth_first_search($graph);
 
     $expected_paths = array(
       1 => array(2, 3, 4),
@@ -106,7 +107,7 @@ class GraphUnitTest extends DrupalUnitTestCase {
    * Verify expected paths in a graph.
    *
    * @param $graph
-   *   A graph array processed by drupal_depth_first_search().
+   *   A graph array processed by depth_first_search().
    * @param $expected_paths
    *   An associative array containing vertices with their expected paths.
    */
@@ -123,7 +124,7 @@ class GraphUnitTest extends DrupalUnitTestCase {
    * Verify expected reverse paths in a graph.
    *
    * @param $graph
-   *   A graph array processed by drupal_depth_first_search().
+   *   A graph array processed by depth_first_search().
    * @param $expected_reverse_paths
    *   An associative array containing vertices with their expected reverse
    *   paths.
@@ -141,7 +142,7 @@ class GraphUnitTest extends DrupalUnitTestCase {
    * Verify expected components in a graph.
    *
    * @param $graph
-   *   A graph array processed by drupal_depth_first_search().
+   *   A graph array processed by depth_first_search().
    * @param $expected_components
    *   An array containing of components defined as a list of their vertices.
    */
@@ -162,7 +163,7 @@ class GraphUnitTest extends DrupalUnitTestCase {
    * Verify expected order in a graph.
    *
    * @param $graph
-   *   A graph array processed by drupal_depth_first_search().
+   *   A graph array processed by depth_first_search().
    * @param $expected_orders
    *   An array containing lists of vertices in their expected order.
    */
diff --git a/core/modules/simpletest/tests/http.php b/core/modules/simpletest/tests/http.php
index 91985a6..5408b2d 100644
--- a/core/modules/simpletest/tests/http.php
+++ b/core/modules/simpletest/tests/http.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -18,15 +19,15 @@ foreach ($_SERVER as $key => $value) {
 
 // Change current directory to the Drupal root.
 chdir('../../../..');
-define('DRUPAL_ROOT', getcwd());
-require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
+define('ROOT', getcwd());
+require_once ROOT . '/core/includes/bootstrap.inc';
 
 // Make sure this file can only be used by simpletest.
-drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
-if (!drupal_valid_test_ua()) {
+bootstrap(BOOTSTRAP_CONFIGURATION);
+if (!valid_test_ua()) {
   header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
   exit;
 }
 
-drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+bootstrap(BOOTSTRAP_FULL);
 menu_execute_active_handler();
diff --git a/core/modules/simpletest/tests/https.php b/core/modules/simpletest/tests/https.php
index c342abc..a26ece6 100644
--- a/core/modules/simpletest/tests/https.php
+++ b/core/modules/simpletest/tests/https.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -17,15 +18,15 @@ foreach ($_SERVER as $key => $value) {
 
 // Change current directory to the Drupal root.
 chdir('../../../..');
-define('DRUPAL_ROOT', getcwd());
-require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
+define('ROOT', getcwd());
+require_once ROOT . '/core/includes/bootstrap.inc';
 
 // Make sure this file can only be used by simpletest.
-drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
-if (!drupal_valid_test_ua()) {
+bootstrap(BOOTSTRAP_CONFIGURATION);
+if (!valid_test_ua()) {
   header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
   exit;
 }
 
-drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+bootstrap(BOOTSTRAP_FULL);
 menu_execute_active_handler();
diff --git a/core/modules/simpletest/tests/image.test b/core/modules/simpletest/tests/image.test
index daf5394..8e83334 100644
--- a/core/modules/simpletest/tests/image.test
+++ b/core/modules/simpletest/tests/image.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -8,7 +10,7 @@
 /**
  * Base class for image manipulation testing.
  */
-class ImageToolkitTestCase extends DrupalWebTestCase {
+class ImageToolkitTestCase extends WebTestCase {
   protected $toolkit;
   protected $file;
   protected $image;
@@ -194,7 +196,7 @@ class ImageToolkitUnitTest extends ImageToolkitTestCase {
 /**
  * Test the core GD image manipulation functions.
  */
-class ImageToolkitGdTestCase extends DrupalWebTestCase {
+class ImageToolkitGdTestCase extends WebTestCase {
   // Colors that are used in testing.
   protected $black       = array(0, 0, 0, 0);
   protected $red         = array(255, 0, 0, 0);
@@ -218,7 +220,7 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
 
   protected function checkRequirements() {
     image_get_available_toolkits();
-    if (!function_exists('image_gd_check_settings') || !image_gd_check_settings()) {
+    if (!function_exists('Drupal\image_gd_check_settings') || !image_gd_check_settings()) {
       return array(
         'Image manipulations for the GD toolkit cannot run because the GD toolkit is not available.',
       );
@@ -386,7 +388,7 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
     foreach ($files as $file) {
       foreach ($operations as $op => $values) {
         // Load up a fresh image.
-        $image = image_load(drupal_get_path('module', 'simpletest') . '/files/' . $file, 'gd');
+        $image = image_load(get_path('module', 'simpletest') . '/files/' . $file, 'gd');
         if (!$image) {
           $this->fail(t('Could not load image %file.', array('%file' => $file)));
           continue 2;
@@ -401,7 +403,7 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
         }
 
         // Perform our operation.
-        $function = 'image_' . $values['function'];
+        $function = 'Drupal\image_' . $values['function'];
         $arguments = array();
         $arguments[] = &$image;
         $arguments = array_merge($arguments, $values['arguments']);
diff --git a/core/modules/simpletest/tests/image_test.module b/core/modules/simpletest/tests/image_test.module
index de640f0..0d83af5 100644
--- a/core/modules/simpletest/tests/image_test.module
+++ b/core/modules/simpletest/tests/image_test.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
diff --git a/core/modules/simpletest/tests/installer.test b/core/modules/simpletest/tests/installer.test
index 82e9957..0f78f91 100644
--- a/core/modules/simpletest/tests/installer.test
+++ b/core/modules/simpletest/tests/installer.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -8,7 +9,7 @@
 /**
  * Tests installer language detection.
  */
-class InstallerLanguageTestCase extends DrupalWebTestCase {
+class InstallerLanguageTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -20,14 +21,14 @@ class InstallerLanguageTestCase extends DrupalWebTestCase {
 
   function setUp() {
     parent::setUp();
-    variable_set('locale_translate_file_directory', drupal_get_path('module', 'simpletest') . '/files/translations');
+    variable_set('locale_translate_file_directory', get_path('module', 'simpletest') . '/files/translations');
   }
 
   /**
    * Tests that the installer can find translation files.
    */
   function testInstallerTranslationFiles() {
-    include_once DRUPAL_ROOT . '/core/includes/install.core.inc';
+    include_once ROOT . '/core/includes/install.core.inc';
 
     // Different translation files would be found depending on which language
     // we are looking for.
diff --git a/core/modules/simpletest/tests/lock.test b/core/modules/simpletest/tests/lock.test
index 0b423ff..eb5370f 100644
--- a/core/modules/simpletest/tests/lock.test
+++ b/core/modules/simpletest/tests/lock.test
@@ -1,9 +1,10 @@
 <?php
+namespace Drupal;
 
 /**
  * Tests for the lock system.
  */
-class LockFunctionalTest extends DrupalWebTestCase {
+class LockFunctionalTest extends WebTestCase {
 
   public static function getInfo() {
     return array(
diff --git a/core/modules/simpletest/tests/mail.test b/core/modules/simpletest/tests/mail.test
index d970b27..762ea77 100644
--- a/core/modules/simpletest/tests/mail.test
+++ b/core/modules/simpletest/tests/mail.test
@@ -1,10 +1,11 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
  * Test the Drupal mailing system.
  */
-class MailTestCase extends DrupalWebTestCase implements MailSystemInterface {
+class MailTestCase extends WebTestCase implements MailSystemInterface {
   /**
    * The most recent message that was sent through the test case.
    *
@@ -35,7 +36,7 @@ class MailTestCase extends DrupalWebTestCase implements MailSystemInterface {
     global $language;
 
     // Use MailTestCase for sending a message.
-    $message = drupal_mail('simpletest', 'mail_test', 'testing@example.com', $language);
+    $message = mail('simpletest', 'mail_test', 'testing@example.com', $language);
 
     // Assert whether the message was sent through the send function.
     $this->assertEqual(self::$sent_message['to'], 'testing@example.com', t('Pluggable mail system is extendable.'));
@@ -53,7 +54,7 @@ class MailTestCase extends DrupalWebTestCase implements MailSystemInterface {
     self::$sent_message = NULL;
 
     // Send a test message that simpletest_mail_alter should cancel.
-    $message = drupal_mail('simpletest', 'cancel_test', 'cancel@example.com', $language);
+    $message = mail('simpletest', 'cancel_test', 'cancel@example.com', $language);
 
     // Assert that the message was not actually sent.
     $this->assertNull(self::$sent_message, 'Message was canceled.');
@@ -68,9 +69,9 @@ class MailTestCase extends DrupalWebTestCase implements MailSystemInterface {
     // Join the body array into one string.
     $message['body'] = implode("\n\n", $message['body']);
     // Convert any HTML to plain-text.
-    $message['body'] = drupal_html_to_text($message['body']);
+    $message['body'] = html_to_text($message['body']);
     // Wrap the mail body for sending.
-    $message['body'] = drupal_wrap_mail($message['body']);
+    $message['body'] = wrap_mail($message['body']);
     return $message;
   }
 
@@ -83,13 +84,13 @@ class MailTestCase extends DrupalWebTestCase implements MailSystemInterface {
 }
 
 /**
- * Unit tests for drupal_html_to_text().
+ * Unit tests for html_to_text().
  */
-class DrupalHtmlToTextTestCase extends DrupalWebTestCase {
+class HtmlToTextTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name'  => 'HTML to text conversion',
-      'description' => 'Tests drupal_html_to_text().',
+      'description' => 'Tests html_to_text().',
       'group' => 'Mail',
     );
   }
@@ -114,7 +115,7 @@ class DrupalHtmlToTextTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Helper function for testing drupal_html_to_text().
+   * Helper function for testing html_to_text().
    *
    * @param $html
    *   The source HTML string to be converted.
@@ -124,13 +125,13 @@ class DrupalHtmlToTextTestCase extends DrupalWebTestCase {
    *   A text message to display in the assertion message.
    * @param $allowed_tags
    *   (optional) An array of allowed tags, or NULL to default to the full
-   *   set of tags supported by drupal_html_to_text().
+   *   set of tags supported by html_to_text().
    */
   function assertHtmlToText($html, $text, $message, $allowed_tags = NULL) {
     preg_match_all('/<([a-z0-6]+)/', drupal_strtolower($html), $matches);
     $tested_tags = implode(', ', array_unique($matches[1]));
     $message .= ' (' . $tested_tags . ')';
-    $result = drupal_html_to_text($html, $allowed_tags);
+    $result = html_to_text($html, $allowed_tags);
     $pass = $this->assertEqual($result, $text, check_plain($message));
     $verbose = 'html = <pre>' . $this->stringToHtml($html)
       . '</pre><br />' . 'result = <pre>' . $this->stringToHtml($result)
@@ -143,7 +144,7 @@ class DrupalHtmlToTextTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Test all supported tags of drupal_html_to_text().
+   * Test all supported tags of html_to_text().
    */
   function testTags() {
     global $base_path, $base_url;
@@ -238,10 +239,10 @@ class DrupalHtmlToTextTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Test $allowed_tags argument of drupal_html_to_text().
+   * Test $allowed_tags argument of html_to_text().
    */
   function testDrupalHtmlToTextArgs() {
-    // The second parameter of drupal_html_to_text() overrules the allowed tags.
+    // The second parameter of html_to_text() overrules the allowed tags.
     $this->assertHtmlToText(
       'Drupal <b>Drupal</b> Drupal',
       "Drupal *Drupal* Drupal\n",
@@ -311,7 +312,7 @@ class DrupalHtmlToTextTestCase extends DrupalWebTestCase {
       . '<ul><li>[ul-li]</li>'
       . '<li>[li-ul]</li></ul>'
       . '[text]';
-    $output = drupal_html_to_text($input);
+    $output = html_to_text($input);
     $pass = $this->assertFalse(
       preg_match('/\][^\n]*\[/s', $output),
       'Block-level HTML tags should force newlines'
@@ -321,7 +322,7 @@ class DrupalHtmlToTextTestCase extends DrupalWebTestCase {
     }
     $output_upper = drupal_strtoupper($output);
     $upper_input = drupal_strtoupper($input);
-    $upper_output = drupal_html_to_text($upper_input);
+    $upper_output = html_to_text($upper_input);
     $pass = $this->assertEqual(
       $upper_output,
       $output_upper,
@@ -407,7 +408,7 @@ class DrupalHtmlToTextTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Tests that drupal_html_to_text() wraps before 1000 characters.
+   * Tests that html_to_text() wraps before 1000 characters.
    *
    * RFC 3676 says, "The Text/Plain media type is the lowest common
    * denominator of Internet email, with lines of no more than 998 characters."
@@ -420,7 +421,7 @@ class DrupalHtmlToTextTestCase extends DrupalWebTestCase {
    */
   function testVeryLongLineWrap() {
     $input = 'Drupal<br /><p>' . str_repeat('x', 2100) . '</><br />Drupal';
-    $output = drupal_html_to_text($input);
+    $output = html_to_text($input);
     // This awkward construct comes from includes/mail.inc lines 8-13.
     $eol = variable_get('mail_line_endings', MAIL_LINE_ENDINGS);
     // We must use strlen() rather than drupal_strlen() in order to count
diff --git a/core/modules/simpletest/tests/menu.test b/core/modules/simpletest/tests/menu.test
index 5a173b1..092d109 100644
--- a/core/modules/simpletest/tests/menu.test
+++ b/core/modules/simpletest/tests/menu.test
@@ -1,11 +1,13 @@
 <?php
+namespace Drupal;
+use PDO;
 
 /**
  * @file
  * Provides SimpleTests for menu.inc.
  */
 
-class MenuWebTestCase extends DrupalWebTestCase {
+class MenuWebTestCase extends WebTestCase {
   function setUp() {
     $modules = func_get_args();
     if (isset($modules[0]) && is_array($modules[0])) {
@@ -17,14 +19,14 @@ class MenuWebTestCase extends DrupalWebTestCase {
   /**
    * Assert that a given path shows certain breadcrumb links.
    *
-   * @param string $goto
-   *   (optional) A system path to pass to DrupalWebTestCase::drupalGet().
+   * @param string $redirect
+   *   (optional) A system path to pass to WebTestCase::drupalGet().
    * @param array $trail
    *   An associative array whose keys are expected breadcrumb link paths and
    *   whose values are expected breadcrumb link texts (not sanitized).
    * @param string $page_title
    *   (optional) A page title to additionally assert via
-   *   DrupalWebTestCase::assertTitle(). Without site name suffix.
+   *   WebTestCase::assertTitle(). Without site name suffix.
    * @param array $tree
    *   (optional) An associative array whose keys are link paths and whose
    *   values are link titles (not sanitized) of an expected active trail in a
@@ -33,9 +35,9 @@ class MenuWebTestCase extends DrupalWebTestCase {
    *   (optional) Whether the last link in $tree is expected to be active (TRUE)
    *   or just to be in the active trail (FALSE).
    */
-  protected function assertBreadcrumb($goto, array $trail, $page_title = NULL, array $tree = array(), $last_active = TRUE) {
-    if (isset($goto)) {
-      $this->drupalGet($goto);
+  protected function assertBreadcrumb($redirect, array $trail, $page_title = NULL, array $tree = array(), $last_active = TRUE) {
+    if (isset($redirect)) {
+      $this->drupalGet($redirect);
     }
     // Compare paths with actual breadcrumb.
     $parts = $this->getParts();
@@ -121,7 +123,7 @@ class MenuWebTestCase extends DrupalWebTestCase {
   }
 }
 
-class MenuRouterTestCase extends DrupalWebTestCase {
+class MenuRouterTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Menu router',
@@ -646,7 +648,7 @@ class MenuRouterTestCase extends DrupalWebTestCase {
 /**
  * Tests for menu links.
  */
-class MenuLinksUnitTestCase extends DrupalWebTestCase {
+class MenuLinksUnitTestCase extends WebTestCase {
   // Use the lightweight testing profile for this test.
   protected $profile = 'testing';
 
@@ -865,7 +867,7 @@ class MenuLinksUnitTestCase extends DrupalWebTestCase {
 /**
  * Tests rebuilding the menu by setting 'menu_rebuild_needed.'
  */
-class MenuRebuildTestCase extends DrupalWebTestCase {
+class MenuRebuildTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Menu rebuild test',
@@ -903,7 +905,7 @@ class MenuRebuildTestCase extends DrupalWebTestCase {
 /**
  * Menu tree data related tests.
  */
-class MenuTreeDataTestCase extends DrupalUnitTestCase {
+class MenuTreeDataTestCase extends UnitTestCase {
   /**
    * Dummy link structure acceptable for menu_tree_data().
    */
@@ -958,7 +960,7 @@ class MenuTreeDataTestCase extends DrupalUnitTestCase {
 /**
  * Menu tree output related tests.
  */
-class MenuTreeOutputTestCase extends DrupalWebTestCase {
+class MenuTreeOutputTestCase extends WebTestCase {
   /**
    * Dummy link structure acceptable for menu_tree_output().
    */
@@ -1368,7 +1370,7 @@ class MenuBreadcrumbTestCase extends MenuWebTestCase {
     // Verify breadcrumbs on user and user/%.
     // We need to log back in and out below, and cannot simply grant the
     // 'administer users' permission, since user_page() makes your head explode.
-    user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_grant_permissions(ANONYMOUS_RID, array(
       'access user profiles',
     ));
     $this->drupalLogout();
diff --git a/core/modules/simpletest/tests/menu_test.module b/core/modules/simpletest/tests/menu_test.module
index c42aca6..59a6ae6 100644
--- a/core/modules/simpletest/tests/menu_test.module
+++ b/core/modules/simpletest/tests/menu_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -382,7 +383,7 @@ function menu_test_menu_trail_callback() {
 function menu_test_theme_page_callback($inherited = FALSE) {
   global $theme_key;
   // Initialize the theme system so that $theme_key will be populated.
-  drupal_theme_initialize();
+  theme_initialize();
   // Now check both the requested custom theme and the actual theme being used.
   $custom_theme = menu_get_custom_theme();
   $requested_theme = empty($custom_theme) ? 'NONE' : $custom_theme;
diff --git a/core/modules/simpletest/tests/module.test b/core/modules/simpletest/tests/module.test
index c9601c9..8c02d9e 100644
--- a/core/modules/simpletest/tests/module.test
+++ b/core/modules/simpletest/tests/module.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -8,7 +9,7 @@
 /**
  * Unit tests for the module API.
  */
-class ModuleUnitTest extends DrupalWebTestCase {
+class ModuleUnitTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Module API',
@@ -56,8 +57,8 @@ class ModuleUnitTest extends DrupalWebTestCase {
 
     // Test the fixed list feature.
     $fixed_list = array(
-      'system' => array('filename' => drupal_get_path('module', 'system')),
-      'menu' => array('filename' => drupal_get_path('module', 'menu')),
+      'system' => array('filename' => get_path('module', 'system')),
+      'menu' => array('filename' => get_path('module', 'menu')),
     );
     module_list(FALSE, FALSE, FALSE, $fixed_list);
     $new_module_list = array_combine(array_keys($fixed_list), array_keys($fixed_list));
@@ -105,7 +106,7 @@ class ModuleUnitTest extends DrupalWebTestCase {
 
     module_load_include('inc', 'module_test', 'module_test.file');
     $modules = module_implements('test_hook');
-    $static = drupal_static('module_implements');
+    $static = drupal_static('Drupal\module_implements');
     $this->assertTrue(in_array('module_test', $modules), 'Hook found.');
     $this->assertEqual($static['test_hook']['module_test'], 'file', 'Include file detected.');
   }
@@ -146,7 +147,7 @@ class ModuleUnitTest extends DrupalWebTestCase {
     // First, create a fake missing dependency. Forum depends on poll, which
     // depends on a made-up module, foo. Nothing should be installed.
     variable_set('dependency_test', 'missing dependency');
-    drupal_static_reset('system_rebuild_module_data');
+    drupal_static_reset('Drupal\system_rebuild_module_data');
     $result = module_enable(array('forum'));
     $this->assertFalse($result, t('module_enable() returns FALSE if dependencies are missing.'));
     $this->assertFalse(module_exists('forum'), t('module_enable() aborts if dependencies are missing.'));
@@ -154,7 +155,7 @@ class ModuleUnitTest extends DrupalWebTestCase {
     // Now, fix the missing dependency. Forum module depends on poll, but poll
     // depends on the PHP module. module_enable() should work.
     variable_set('dependency_test', 'dependency');
-    drupal_static_reset('system_rebuild_module_data');
+    drupal_static_reset('Drupal\system_rebuild_module_data');
     $result = module_enable(array('forum'));
     $this->assertTrue($result, t('module_enable() returns the correct value.'));
     // Verify that the fake dependency chain was installed.
@@ -174,7 +175,7 @@ class ModuleUnitTest extends DrupalWebTestCase {
     // Disable a module that is listed as a dependency by the install profile.
     // Make sure that the profile itself is not on the list of dependent
     // modules to be disabled.
-    $profile = drupal_get_profile();
+    $profile = get_profile();
     $info = install_profile_info($profile);
     $this->assertTrue(in_array('comment', $info['dependencies']), t('Comment module is listed as a dependency of the install profile.'));
     $this->assertTrue(module_exists('comment'), t('Comment module is enabled.'));
@@ -187,27 +188,27 @@ class ModuleUnitTest extends DrupalWebTestCase {
     // Try to uninstall the PHP module by itself. This should be rejected,
     // since the modules which it depends on need to be uninstalled first, and
     // that is too destructive to perform automatically.
-    $result = drupal_uninstall_modules(array('php'));
-    $this->assertFalse($result, t('Calling drupal_uninstall_modules() on a module whose dependents are not uninstalled fails.'));
+    $result = uninstall_modules(array('php'));
+    $this->assertFalse($result, t('Calling uninstall_modules() on a module whose dependents are not uninstalled fails.'));
     foreach (array('forum', 'poll', 'php') as $module) {
-      $this->assertNotEqual(drupal_get_installed_schema_version($module), SCHEMA_UNINSTALLED, t('The @module module was not uninstalled.', array('@module' => $module)));
+      $this->assertNotEqual(get_installed_schema_version($module), SCHEMA_UNINSTALLED, t('The @module module was not uninstalled.', array('@module' => $module)));
     }
 
     // Now uninstall all three modules explicitly, but in the incorrect order,
     // and make sure that drupal_uninstal_modules() uninstalled them in the
     // correct sequence.
-    $result = drupal_uninstall_modules(array('poll', 'php', 'forum'));
-    $this->assertTrue($result, t('drupal_uninstall_modules() returns the correct value.'));
+    $result = uninstall_modules(array('poll', 'php', 'forum'));
+    $this->assertTrue($result, t('uninstall_modules() returns the correct value.'));
     foreach (array('forum', 'poll', 'php') as $module) {
-      $this->assertEqual(drupal_get_installed_schema_version($module), SCHEMA_UNINSTALLED, t('The @module module was uninstalled.', array('@module' => $module)));
+      $this->assertEqual(get_installed_schema_version($module), SCHEMA_UNINSTALLED, t('The @module module was uninstalled.', array('@module' => $module)));
     }
-    $this->assertEqual(variable_get('test_module_uninstall_order', array()), array('forum', 'poll', 'php'), t('Modules were uninstalled in the correct order by drupal_uninstall_modules().'));
+    $this->assertEqual(variable_get('test_module_uninstall_order', array()), array('forum', 'poll', 'php'), t('Modules were uninstalled in the correct order by uninstall_modules().'));
 
     // Uninstall the profile module from above, and make sure that the profile
     // itself is not on the list of dependent modules to be uninstalled.
-    $result = drupal_uninstall_modules(array('comment'));
-    $this->assertTrue($result, t('drupal_uninstall_modules() returns the correct value.'));
-    $this->assertEqual(drupal_get_installed_schema_version('comment'), SCHEMA_UNINSTALLED, t('Comment module was uninstalled.'));
+    $result = uninstall_modules(array('comment'));
+    $this->assertTrue($result, t('uninstall_modules() returns the correct value.'));
+    $this->assertEqual(get_installed_schema_version('comment'), SCHEMA_UNINSTALLED, t('Comment module was uninstalled.'));
     $uninstalled_modules = variable_get('test_module_uninstall_order', array());
     $this->assertTrue(in_array('comment', $uninstalled_modules), t('Comment module is in the list of uninstalled modules.'));
     $this->assertFalse(in_array($profile, $uninstalled_modules), t('The installation profile is not in the list of uninstalled modules.'));
@@ -217,7 +218,7 @@ class ModuleUnitTest extends DrupalWebTestCase {
     // on a specific version of php module in its info file. Make sure that
     // module_enable() still works.
     variable_set('dependency_test', 'version dependency');
-    drupal_static_reset('system_rebuild_module_data');
+    drupal_static_reset('Drupal\system_rebuild_module_data');
     $result = module_enable(array('forum'));
     $this->assertTrue($result, t('module_enable() returns the correct value.'));
     // Verify that the fake dependency chain was installed.
@@ -238,7 +239,7 @@ class ModuleUnitTest extends DrupalWebTestCase {
 /**
  * Unit tests for module installation.
  */
-class ModuleInstallTestCase extends DrupalWebTestCase {
+class ModuleInstallTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Module installation',
@@ -252,11 +253,11 @@ class ModuleInstallTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Test that calls to drupal_write_record() work during module installation.
+   * Test that calls to write_record() work during module installation.
    *
    * This is a useful function to test because modules often use it to insert
    * initial data in their database tables when they are being installed or
-   * enabled. Furthermore, drupal_write_record() relies on the module schema
+   * enabled. Furthermore, write_record() relies on the module schema
    * information being available, so this also checks that the data from one of
    * the module's hook implementations, in particular hook_schema(), is
    * properly available during this time. Therefore, this test helps ensure
@@ -264,18 +265,18 @@ class ModuleInstallTestCase extends DrupalWebTestCase {
    * them.
    */
   function testDrupalWriteRecord() {
-    // Check for data that was inserted using drupal_write_record() while the
+    // Check for data that was inserted using write_record() while the
     // 'module_test' module was being installed and enabled.
     $data = db_query("SELECT data FROM {module_test}")->fetchCol();
-    $this->assertTrue(in_array('Data inserted in hook_install()', $data), t('Data inserted using drupal_write_record() in hook_install() is correctly saved.'));
-    $this->assertTrue(in_array('Data inserted in hook_enable()', $data), t('Data inserted using drupal_write_record() in hook_enable() is correctly saved.'));
+    $this->assertTrue(in_array('Data inserted in hook_install()', $data), t('Data inserted using write_record() in hook_install() is correctly saved.'));
+    $this->assertTrue(in_array('Data inserted in hook_enable()', $data), t('Data inserted using write_record() in hook_enable() is correctly saved.'));
   }
 }
 
 /**
  * Unit tests for module uninstallation and related hooks.
  */
-class ModuleUninstallTestCase extends DrupalWebTestCase {
+class ModuleUninstallTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Module uninstallation',
@@ -295,7 +296,7 @@ class ModuleUninstallTestCase extends DrupalWebTestCase {
     // Uninstalls the module_test module, so hook_modules_uninstalled()
     // is executed.
     module_disable(array('module_test'));
-    drupal_uninstall_modules(array('module_test'));
+    uninstall_modules(array('module_test'));
 
     // Are the perms defined by module_test removed from {role_permission}.
     $count = db_query("SELECT COUNT(rid) FROM {role_permission} WHERE permission = :perm", array(':perm' => 'module_test perm'))->fetchField();
diff --git a/core/modules/simpletest/tests/module_test.file.inc b/core/modules/simpletest/tests/module_test.file.inc
index c0d3ec4..8c678c6 100644
--- a/core/modules/simpletest/tests/module_test.file.inc
+++ b/core/modules/simpletest/tests/module_test.file.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/simpletest/tests/module_test.install b/core/modules/simpletest/tests/module_test.install
index 4cc09df..b48bf0b 100644
--- a/core/modules/simpletest/tests/module_test.install
+++ b/core/modules/simpletest/tests/module_test.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -29,7 +30,7 @@ function module_test_schema() {
  */
 function module_test_install() {
   $record = array('data' => 'Data inserted in hook_install()');
-  drupal_write_record('module_test', $record);
+  write_record('module_test', $record);
 }
 
 /**
@@ -37,6 +38,6 @@ function module_test_install() {
  */
 function module_test_enable() {
   $record = array('data' => 'Data inserted in hook_enable()');
-  drupal_write_record('module_test', $record);
+  write_record('module_test', $record);
 }
 
diff --git a/core/modules/simpletest/tests/module_test.module b/core/modules/simpletest/tests/module_test.module
index bd85049..be3270f 100644
--- a/core/modules/simpletest/tests/module_test.module
+++ b/core/modules/simpletest/tests/module_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Implements hook_permission().
diff --git a/core/modules/simpletest/tests/password.test b/core/modules/simpletest/tests/password.test
index e0139e9..eea660f 100644
--- a/core/modules/simpletest/tests/password.test
+++ b/core/modules/simpletest/tests/password.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -8,7 +9,7 @@
 /**
  * Unit tests for password hashing API.
  */
-class PasswordHashingTest extends DrupalWebTestCase {
+class PasswordHashingTest extends WebTestCase {
   protected $profile = 'testing';
 
   public static function getInfo() {
@@ -20,7 +21,7 @@ class PasswordHashingTest extends DrupalWebTestCase {
   }
 
   function setUp() {
-    require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'core/includes/password.inc');
+    require_once ROOT . '/' . variable_get('password_inc', 'core/includes/password.inc');
     parent::setUp();
   }
 
@@ -39,19 +40,19 @@ class PasswordHashingTest extends DrupalWebTestCase {
     // Re-hash the password.
     $old_hash = $account->pass;
     $account->pass = user_hash_password($password);
-    $this->assertIdentical(_password_get_count_log2($account->pass), DRUPAL_MIN_HASH_COUNT, t('Re-hashed password has the minimum number of log2 iterations.'));
+    $this->assertIdentical(_password_get_count_log2($account->pass), MIN_HASH_COUNT, t('Re-hashed password has the minimum number of log2 iterations.'));
     $this->assertTrue($account->pass != $old_hash, t('Password hash changed.'));
     $this->assertTrue(user_check_password($password, $account), t('Password check succeeds.'));
     // Since the log2 setting hasn't changed and the user has a valid password,
     // user_needs_new_hash() should return FALSE.
     $this->assertFalse(user_needs_new_hash($account), t('User does not need a new hash.'));
     // Increment the log2 iteration to MIN + 1.
-    variable_set('password_count_log2', DRUPAL_MIN_HASH_COUNT + 1);
+    variable_set('password_count_log2', MIN_HASH_COUNT + 1);
     $this->assertTrue(user_needs_new_hash($account), t('User needs a new hash after incrementing the log2 count.'));
     // Re-hash the password.
     $old_hash = $account->pass;
     $account->pass = user_hash_password($password);
-    $this->assertIdentical(_password_get_count_log2($account->pass), DRUPAL_MIN_HASH_COUNT + 1, t('Re-hashed password has the correct number of log2 iterations.'));
+    $this->assertIdentical(_password_get_count_log2($account->pass), MIN_HASH_COUNT + 1, t('Re-hashed password has the correct number of log2 iterations.'));
     $this->assertTrue($account->pass != $old_hash, t('Password hash changed again.'));
     // Now the hash should be OK.
     $this->assertFalse(user_needs_new_hash($account), t('Re-hashed password does not need a new hash.'));
diff --git a/core/modules/simpletest/tests/path.test b/core/modules/simpletest/tests/path.test
index 18dab6b..910e53a 100644
--- a/core/modules/simpletest/tests/path.test
+++ b/core/modules/simpletest/tests/path.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -6,17 +7,17 @@
  */
 
 /**
- * Unit tests for the drupal_match_path() function in path.inc.
+ * Unit tests for the match_path() function in path.inc.
  *
- * @see drupal_match_path().
+ * @see match_path().
  */
-class DrupalMatchPathTestCase extends DrupalWebTestCase {
+class MatchPathTestCase extends WebTestCase {
   protected $front;
 
   public static function getInfo() {
     return array(
       'name' => 'Drupal match path',
-      'description' => 'Tests the drupal_match_path() function to make sure it works properly.',
+      'description' => 'Tests the match_path() function to make sure it works properly.',
       'group' => 'Path API',
     );
   }
@@ -40,7 +41,7 @@ class DrupalMatchPathTestCase extends DrupalWebTestCase {
     $tests = $this->drupalMatchPathTests();
     foreach ($tests as $patterns => $cases) {
       foreach ($cases as $path => $expected_result) {
-        $actual_result = drupal_match_path($path, $patterns);
+        $actual_result = match_path($path, $patterns);
         $this->assertIdentical($actual_result, $expected_result, t('Tried matching the path <code>@path</code> to the pattern <pre>@patterns</pre> - expected @expected, got @actual.', array('@path' => $path, '@patterns' => $patterns, '@expected' => var_export($expected_result, TRUE), '@actual' => var_export($actual_result, TRUE))));
       }
     }
@@ -129,7 +130,7 @@ class DrupalMatchPathTestCase extends DrupalWebTestCase {
 /**
  * Tests hook_url_alter functions.
  */
-class UrlAlterFunctionalTest extends DrupalWebTestCase {
+class UrlAlterFunctionalTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => t('URL altering'),
@@ -231,7 +232,7 @@ class UrlAlterFunctionalTest extends DrupalWebTestCase {
    *
    * @param $original
    *   A string with the aliased or un-normal path that is run through
-   *   drupal_get_normal_path().
+   *   get_normal_path().
    * @param $final
    *   A string with the expected result after url().
    * @return
@@ -239,25 +240,25 @@ class UrlAlterFunctionalTest extends DrupalWebTestCase {
    */
   protected function assertUrlInboundAlter($original, $final) {
     // Test inbound altering.
-    $result = drupal_get_normal_path($original);
+    $result = get_normal_path($original);
     $this->assertIdentical($result, $final, t('Altered inbound URL %original, expected %final, and got %result.', array('%original' => $original, '%final' => $final, '%result' => $result)));
   }
 }
 
 /**
- * Unit test for drupal_lookup_path().
+ * Unit test for lookup_path().
  */
-class PathLookupTest extends DrupalWebTestCase {
+class PathLookupTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => t('Path lookup'),
-      'description' => t('Tests that drupal_lookup_path() returns correct paths.'),
+      'description' => t('Tests that lookup_path() returns correct paths.'),
       'group' => t('Path API'),
     );
   }
 
   /**
-   * Test that drupal_lookup_path() returns the correct path.
+   * Test that lookup_path() returns the correct path.
    */
   function testDrupalLookupPath() {
     $account = $this->drupalCreateUser();
@@ -271,8 +272,8 @@ class PathLookupTest extends DrupalWebTestCase {
       'alias' => 'foo',
     );
     path_save($path);
-    $this->assertEqual(drupal_lookup_path('alias', $path['source']), $path['alias'], t('Basic alias lookup works.'));
-    $this->assertEqual(drupal_lookup_path('source', $path['alias']), $path['source'], t('Basic source lookup works.'));
+    $this->assertEqual(lookup_path('alias', $path['source']), $path['alias'], t('Basic alias lookup works.'));
+    $this->assertEqual(lookup_path('source', $path['alias']), $path['source'], t('Basic source lookup works.'));
 
     // Create a language specific alias for the default language (English).
     $path = array(
@@ -281,8 +282,8 @@ class PathLookupTest extends DrupalWebTestCase {
       'langcode' => 'en',
     );
     path_save($path);
-    $this->assertEqual(drupal_lookup_path('alias', $path['source']), $path['alias'], t('English alias overrides language-neutral alias.'));
-    $this->assertEqual(drupal_lookup_path('source', $path['alias']), $path['source'], t('English source overrides language-neutral source.'));
+    $this->assertEqual(lookup_path('alias', $path['source']), $path['alias'], t('English alias overrides language-neutral alias.'));
+    $this->assertEqual(lookup_path('source', $path['alias']), $path['source'], t('English source overrides language-neutral source.'));
 
     // Create a language-neutral alias for the same path, again.
     $path = array(
@@ -290,7 +291,7 @@ class PathLookupTest extends DrupalWebTestCase {
       'alias' => 'bar',
     );
     path_save($path);
-    $this->assertEqual(drupal_lookup_path('alias', $path['source']), "users/$name", t('English alias still returned after entering a language-neutral alias.'));
+    $this->assertEqual(lookup_path('alias', $path['source']), "users/$name", t('English alias still returned after entering a language-neutral alias.'));
 
     // Create a language-specific (xx-lolspeak) alias for the same path.
     $path = array(
@@ -299,9 +300,9 @@ class PathLookupTest extends DrupalWebTestCase {
       'langcode' => 'xx-lolspeak',
     );
     path_save($path);
-    $this->assertEqual(drupal_lookup_path('alias', $path['source']), "users/$name", t('English alias still returned after entering a LOLspeak alias.'));
+    $this->assertEqual(lookup_path('alias', $path['source']), "users/$name", t('English alias still returned after entering a LOLspeak alias.'));
     // The LOLspeak alias should be returned if we really want LOLspeak.
-    $this->assertEqual(drupal_lookup_path('alias', $path['source'], 'xx-lolspeak'), 'LOL', t('LOLspeak alias returned if we specify xx-lolspeak to drupal_lookup_path().'));
+    $this->assertEqual(lookup_path('alias', $path['source'], 'xx-lolspeak'), 'LOL', t('LOLspeak alias returned if we specify xx-lolspeak to lookup_path().'));
 
     // Create a new alias for this path in English, which should override the
     // previous alias for "user/$uid".
@@ -311,16 +312,16 @@ class PathLookupTest extends DrupalWebTestCase {
       'langcode' => 'en',
     );
     path_save($path);
-    $this->assertEqual(drupal_lookup_path('alias', $path['source']), $path['alias'], t('Recently created English alias returned.'));
-    $this->assertEqual(drupal_lookup_path('source', $path['alias']), $path['source'], t('Recently created English source returned.'));
+    $this->assertEqual(lookup_path('alias', $path['source']), $path['alias'], t('Recently created English alias returned.'));
+    $this->assertEqual(lookup_path('source', $path['alias']), $path['source'], t('Recently created English source returned.'));
 
     // Remove the English aliases, which should cause a fallback to the most
     // recently created language-neutral alias, 'bar'.
     db_delete('url_alias')
       ->condition('langcode', 'en')
       ->execute();
-    drupal_clear_path_cache();
-    $this->assertEqual(drupal_lookup_path('alias', $path['source']), 'bar', t('Path lookup falls back to recently created language-neutral alias.'));
+    clear_path_cache();
+    $this->assertEqual(lookup_path('alias', $path['source']), 'bar', t('Path lookup falls back to recently created language-neutral alias.'));
 
     // Test the situation where the alias and language are the same, but
     // the source differs. The newer alias record should be returned.
@@ -330,6 +331,6 @@ class PathLookupTest extends DrupalWebTestCase {
       'alias' => 'bar',
     );
     path_save($path);
-    $this->assertEqual(drupal_lookup_path('source', $path['alias']), $path['source'], t('Newer alias record is returned when comparing two LANGUAGE_NONE paths with the same alias.'));
+    $this->assertEqual(lookup_path('source', $path['alias']), $path['source'], t('Newer alias record is returned when comparing two LANGUAGE_NONE paths with the same alias.'));
   }
 }
diff --git a/core/modules/simpletest/tests/registry.test b/core/modules/simpletest/tests/registry.test
index bcd8d4e..a2bdc5e 100644
--- a/core/modules/simpletest/tests/registry.test
+++ b/core/modules/simpletest/tests/registry.test
@@ -1,6 +1,8 @@
 <?php
+namespace Drupal;
+use stdClass;
 
-class RegistryParseFileTestCase extends DrupalWebTestCase {
+class RegistryParseFileTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Registry parse file test',
@@ -45,7 +47,7 @@ CONTENTS;
 
 }
 
-class RegistryParseFilesTestCase extends DrupalWebTestCase {
+class RegistryParseFilesTestCase extends WebTestCase {
   protected $fileTypes = array('new', 'existing_changed');
 
   public static function getInfo() {
diff --git a/core/modules/simpletest/tests/requirements1_test.install b/core/modules/simpletest/tests/requirements1_test.install
index 651d911..1e7f065 100644
--- a/core/modules/simpletest/tests/requirements1_test.install
+++ b/core/modules/simpletest/tests/requirements1_test.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Implements hook_requirements().
diff --git a/core/modules/simpletest/tests/requirements1_test.module b/core/modules/simpletest/tests/requirements1_test.module
index e52266b..2e91393 100644
--- a/core/modules/simpletest/tests/requirements1_test.module
+++ b/core/modules/simpletest/tests/requirements1_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/simpletest/tests/requirements2_test.module b/core/modules/simpletest/tests/requirements2_test.module
index a4f4305..5b233be 100644
--- a/core/modules/simpletest/tests/requirements2_test.module
+++ b/core/modules/simpletest/tests/requirements2_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/simpletest/tests/schema.test b/core/modules/simpletest/tests/schema.test
index 8945117..d8e9737 100644
--- a/core/modules/simpletest/tests/schema.test
+++ b/core/modules/simpletest/tests/schema.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -8,7 +10,7 @@
 /**
  * Unit tests for the Schema API.
  */
-class SchemaTestCase extends DrupalWebTestCase {
+class SchemaTestCase extends WebTestCase {
   /**
    * A global counter for table and field creation.
    */
diff --git a/core/modules/simpletest/tests/session.test b/core/modules/simpletest/tests/session.test
index 846f6d3..92eef6c 100644
--- a/core/modules/simpletest/tests/session.test
+++ b/core/modules/simpletest/tests/session.test
@@ -1,11 +1,12 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
  * Provides SimpleTests for core session handling functionality.
  */
 
-class SessionTestCase extends DrupalWebTestCase {
+class SessionTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Session tests',
@@ -19,14 +20,14 @@ class SessionTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Tests for drupal_save_session() and drupal_session_regenerate().
+   * Tests for save_session() and session_regenerate().
    */
   function testSessionSaveRegenerate() {
-    $this->assertFalse(drupal_save_session(), t('drupal_save_session() correctly returns FALSE (inside of testing framework) when initially called with no arguments.'), t('Session'));
-    $this->assertFalse(drupal_save_session(FALSE), t('drupal_save_session() correctly returns FALSE when called with FALSE.'), t('Session'));
-    $this->assertFalse(drupal_save_session(), t('drupal_save_session() correctly returns FALSE when saving has been disabled.'), t('Session'));
-    $this->assertTrue(drupal_save_session(TRUE), t('drupal_save_session() correctly returns TRUE when called with TRUE.'), t('Session'));
-    $this->assertTrue(drupal_save_session(), t('drupal_save_session() correctly returns TRUE when saving has been enabled.'), t('Session'));
+    $this->assertFalse(save_session(), t('save_session() correctly returns FALSE (inside of testing framework) when initially called with no arguments.'), t('Session'));
+    $this->assertFalse(save_session(FALSE), t('save_session() correctly returns FALSE when called with FALSE.'), t('Session'));
+    $this->assertFalse(save_session(), t('save_session() correctly returns FALSE when saving has been disabled.'), t('Session'));
+    $this->assertTrue(save_session(TRUE), t('save_session() correctly returns TRUE when called with TRUE.'), t('Session'));
+    $this->assertTrue(save_session(), t('save_session() correctly returns TRUE when saving has been enabled.'), t('Session'));
 
     // Test session hardening code from SA-2008-044.
     $user = $this->drupalCreateUser(array('access content'));
@@ -84,13 +85,13 @@ class SessionTestCase extends DrupalWebTestCase {
     $this->drupalGet('session-test/get');
     $this->assertText($value_1, t('Session correctly returned the stored data for an authenticated user.'), t('Session'));
 
-    // Attempt to write over val_1. If drupal_save_session(FALSE) is working.
+    // Attempt to write over val_1. If save_session(FALSE) is working.
     // properly, val_1 will still be set.
     $value_2 = $this->randomName();
     $this->drupalGet('session-test/no-set/' . $value_2);
     $this->assertText($value_2, t('The session value was correctly passed to session-test/no-set.'), t('Session'));
     $this->drupalGet('session-test/get');
-    $this->assertText($value_1, t('Session data is not saved for drupal_save_session(FALSE).'), t('Session'));
+    $this->assertText($value_1, t('Session data is not saved for save_session(FALSE).'), t('Session'));
 
     // Switch browser cookie to anonymous user, then back to user 1.
     $this->sessionReset();
@@ -110,12 +111,12 @@ class SessionTestCase extends DrupalWebTestCase {
     $this->drupalGet('session-test/get');
     $this->assertText($value_3, t('Session correctly returned the stored data for an anonymous user.'), t('Session'));
 
-    // Try to store data when drupal_save_session(FALSE).
+    // Try to store data when save_session(FALSE).
     $value_4 = $this->randomName();
     $this->drupalGet('session-test/no-set/' . $value_4);
     $this->assertText($value_4, t('The session value was correctly passed to session-test/no-set.'), t('Session'));
     $this->drupalGet('session-test/get');
-    $this->assertText($value_3, t('Session data is not saved for drupal_save_session(FALSE).'), t('Session'));
+    $this->assertText($value_3, t('Session data is not saved for save_session(FALSE).'), t('Session'));
 
     // Login, the data should persist.
     $this->drupalLogin($user);
@@ -167,7 +168,7 @@ class SessionTestCase extends DrupalWebTestCase {
     $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', t('Page was cached.'));
     $this->assertFalse($this->drupalGetHeader('Set-Cookie'), t('New session was not started.'));
 
-    // Verify that no session is created if drupal_save_session(FALSE) is called.
+    // Verify that no session is created if save_session(FALSE) is called.
     $this->drupalGet('session-test/set-message-but-dont-save');
     $this->assertSessionCookie(FALSE);
     $this->assertSessionEmpty(TRUE);
@@ -291,7 +292,7 @@ class SessionTestCase extends DrupalWebTestCase {
 /**
  * Ensure that when running under https two session cookies are generated.
  */
-class SessionHttpsTestCase extends DrupalWebTestCase {
+class SessionHttpsTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
diff --git a/core/modules/simpletest/tests/session_test.module b/core/modules/simpletest/tests/session_test.module
index 689ff09..9d602c1 100644
--- a/core/modules/simpletest/tests/session_test.module
+++ b/core/modules/simpletest/tests/session_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Implements hook_menu().
@@ -96,7 +97,7 @@ function _session_test_set($value) {
  * anyway.
  */
 function _session_test_no_set($value) {
-  drupal_save_session(FALSE);
+  save_session(FALSE);
   _session_test_set($value);
   return t('session saving was disabled, and then %val was set', array('%val' => $value));
 }
@@ -105,11 +106,11 @@ function _session_test_no_set($value) {
  * Menu callback: print the current session ID.
  */
 function _session_test_id() {
-  // Set a value in $_SESSION, so that drupal_session_commit() will start
+  // Set a value in $_SESSION, so that session_commit() will start
   // a session.
   $_SESSION['test'] = 'test';
 
-  drupal_session_commit();
+  session_commit();
 
   return 'session_id:' . session_id() . "\n";
 }
@@ -125,7 +126,7 @@ function _session_test_id_from_cookie() {
  * Menu callback, sets a message to me displayed on the following page.
  */
 function _session_test_set_message() {
-  drupal_set_message(t('This is a dummy message.'));
+  set_message(t('This is a dummy message.'));
   print t('A message was set.');
   // Do not return anything, so the current request does not result in a themed
   // page with messages. The message will be displayed in the following request
@@ -133,10 +134,10 @@ function _session_test_set_message() {
 }
 
 /**
- * Menu callback, sets a message but call drupal_save_session(FALSE).
+ * Menu callback, sets a message but call save_session(FALSE).
  */
 function _session_test_set_message_but_dont_save() {
-  drupal_save_session(FALSE);
+  save_session(FALSE);
   _session_test_set_message();
 }
 
@@ -169,12 +170,12 @@ function session_test_form_user_login_alter(&$form) {
 }
 
 /**
- * Implements hook_drupal_goto_alter().
+ * Implements hook_redirect_alter().
  *
  * Force the redirection to go to a non-secure page after being on a secure
  * page through https.php.
  */
-function session_test_drupal_goto_alter(&$path, &$options, &$http_response_code) {
+function session_test_redirect_alter(&$path, &$options, &$http_response_code) {
   global $base_insecure_url, $is_https_mock;
   // Alter the redirect to use HTTP when using a mock HTTPS request through
   // https.php because form submissions would otherwise redirect to a
diff --git a/core/modules/simpletest/tests/symfony.test b/core/modules/simpletest/tests/symfony.test
index 8a7ecb9..5253839 100644
--- a/core/modules/simpletest/tests/symfony.test
+++ b/core/modules/simpletest/tests/symfony.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -8,7 +9,7 @@
 /**
  * Tests related to Symfony class loading.
  */
-class SymfonyClassLoaderTestCase extends DrupalUnitTestCase {
+class SymfonyClassLoaderTestCase extends UnitTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Class loader',
diff --git a/core/modules/simpletest/tests/system_dependencies_test.module b/core/modules/simpletest/tests/system_dependencies_test.module
index b3d9bbc..66bf2d1 100644
--- a/core/modules/simpletest/tests/system_dependencies_test.module
+++ b/core/modules/simpletest/tests/system_dependencies_test.module
@@ -1 +1,2 @@
 <?php
+namespace Drupal;
diff --git a/core/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.module b/core/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.module
index b3d9bbc..66bf2d1 100644
--- a/core/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.module
+++ b/core/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.module
@@ -1 +1,2 @@
 <?php
+namespace Drupal;
diff --git a/core/modules/simpletest/tests/system_incompatible_core_version_test.module b/core/modules/simpletest/tests/system_incompatible_core_version_test.module
index b3d9bbc..66bf2d1 100644
--- a/core/modules/simpletest/tests/system_incompatible_core_version_test.module
+++ b/core/modules/simpletest/tests/system_incompatible_core_version_test.module
@@ -1 +1,2 @@
 <?php
+namespace Drupal;
diff --git a/core/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.module b/core/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.module
index b3d9bbc..66bf2d1 100644
--- a/core/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.module
+++ b/core/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.module
@@ -1 +1,2 @@
 <?php
+namespace Drupal;
diff --git a/core/modules/simpletest/tests/system_incompatible_module_version_test.module b/core/modules/simpletest/tests/system_incompatible_module_version_test.module
index b3d9bbc..66bf2d1 100644
--- a/core/modules/simpletest/tests/system_incompatible_module_version_test.module
+++ b/core/modules/simpletest/tests/system_incompatible_module_version_test.module
@@ -1 +1,2 @@
 <?php
+namespace Drupal;
diff --git a/core/modules/simpletest/tests/system_test.module b/core/modules/simpletest/tests/system_test.module
index e6d1f35..3321321 100644
--- a/core/modules/simpletest/tests/system_test.module
+++ b/core/modules/simpletest/tests/system_test.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * Implements hook_menu().
@@ -154,7 +156,7 @@ function system_test_multiple_redirects($count) {
 }
 
 function system_test_set_header() {
-  drupal_add_http_header($_GET['name'], $_GET['value']);
+  add_http_header($_GET['name'], $_GET['value']);
   return t('The following header was set: %name: %value', array('%name' => $_GET['name'], '%value' => $_GET['value']));
 }
 
@@ -179,7 +181,7 @@ function system_test_redirect_invalid_scheme() {
 function system_test_modules_installed($modules) {
   if (variable_get('test_verbose_module_hooks')) {
     foreach ($modules as $module) {
-      drupal_set_message(t('hook_modules_installed fired for @module', array('@module' => $module)));
+      set_message(t('hook_modules_installed fired for @module', array('@module' => $module)));
     }
   }
 }
@@ -190,7 +192,7 @@ function system_test_modules_installed($modules) {
 function system_test_modules_enabled($modules) {
   if (variable_get('test_verbose_module_hooks')) {
     foreach ($modules as $module) {
-      drupal_set_message(t('hook_modules_enabled fired for @module', array('@module' => $module)));
+      set_message(t('hook_modules_enabled fired for @module', array('@module' => $module)));
     }
   }
 }
@@ -201,7 +203,7 @@ function system_test_modules_enabled($modules) {
 function system_test_modules_disabled($modules) {
   if (variable_get('test_verbose_module_hooks')) {
     foreach ($modules as $module) {
-      drupal_set_message(t('hook_modules_disabled fired for @module', array('@module' => $module)));
+      set_message(t('hook_modules_disabled fired for @module', array('@module' => $module)));
     }
   }
 }
@@ -212,7 +214,7 @@ function system_test_modules_disabled($modules) {
 function system_test_modules_uninstalled($modules) {
   if (variable_get('test_verbose_module_hooks')) {
     foreach ($modules as $module) {
-      drupal_set_message(t('hook_modules_uninstalled fired for @module', array('@module' => $module)));
+      set_message(t('hook_modules_uninstalled fired for @module', array('@module' => $module)));
     }
   }
 }
@@ -228,9 +230,9 @@ function system_test_boot() {
  * Implements hook_init().
  */
 function system_test_init() {
-  // Used by FrontPageTestCase to get the results of drupal_is_front_page().
-  if (variable_get('front_page_output', 0) && drupal_is_front_page()) {
-    drupal_set_message(t('On front page.'));
+  // Used by FrontPageTestCase to get the results of is_front_page().
+  if (variable_get('front_page_output', 0) && is_front_page()) {
+    set_message(t('On front page.'));
   }
 }
 
@@ -312,15 +314,15 @@ function system_test_page_build(&$page) {
   $main_content_display = &drupal_static('system_main_content_added', FALSE);
 
   if ($menu_item['path'] == 'system-test/main-content-handling') {
-    $page['footer'] = drupal_set_page_content();
+    $page['footer'] = set_page_content();
     $page['footer']['main']['#markup'] = '<div id="system-test-content">' . $page['footer']['main']['#markup'] . '</div>';
   }
   elseif ($menu_item['path'] == 'system-test/main-content-fallback') {
-    drupal_set_page_content();
+    set_page_content();
     $main_content_display = FALSE;
   }
   elseif ($menu_item['path'] == 'system-test/main-content-duplication') {
-    drupal_set_page_content();
+    set_page_content();
   }
 }
 
@@ -335,7 +337,7 @@ function system_test_main_content_fallback() {
  * A simple page callback which adds a register shutdown function.
  */
 function system_test_page_shutdown_functions($arg1, $arg2) {
-  drupal_register_shutdown_function('_system_test_first_shutdown_function', $arg1, $arg2);
+  drupal_register_shutdown_function('Drupal\_system_test_first_shutdown_function', $arg1, $arg2);
 }
 
 /**
@@ -343,9 +345,9 @@ function system_test_page_shutdown_functions($arg1, $arg2) {
  */
 function _system_test_first_shutdown_function($arg1, $arg2) {
   // Output something, page has already been printed and the session stored
-  // so we can't use drupal_set_message.
+  // so we can't use set_message.
   print t('First shutdown function, arg1 : @arg1, arg2: @arg2', array('@arg1' => $arg1, '@arg2' => $arg2));
-  drupal_register_shutdown_function('_system_test_second_shutdown_function', $arg1, $arg2);
+  drupal_register_shutdown_function('Drupal\_system_test_second_shutdown_function', $arg1, $arg2);
 }
 
 /**
@@ -353,13 +355,13 @@ function _system_test_first_shutdown_function($arg1, $arg2) {
  */
 function _system_test_second_shutdown_function($arg1, $arg2) {
   // Output something, page has already been printed and the session stored
-  // so we can't use drupal_set_message.
+  // so we can't use set_message.
   print t('Second shutdown function, arg1 : @arg1, arg2: @arg2', array('@arg1' => $arg1, '@arg2' => $arg2));
 
   // Throw an exception with an HTML tag. Since this is called in a shutdown
   // function, it will not bubble up to the default exception handler but will
-  // be caught in _drupal_shutdown_function() and be displayed through
-  // _drupal_render_exception_safe().
+  // be caught in _shutdown_function() and be displayed through
+  // _render_exception_safe().
   throw new Exception('Drupal is <blink>awesome</blink>.');
 }
 
@@ -402,6 +404,6 @@ class SystemTestFileTransfer {
  */
 function system_test_authorize_init_page($page_title) {
   $authorize_url = $GLOBALS['base_url'] . '/core/authorize.php';
-  system_authorized_init('system_test_authorize_run', drupal_get_path('module', 'system_test') . '/system_test.module', array(), $page_title);
-  drupal_goto($authorize_url);
+  system_authorized_init('system_test_authorize_run', get_path('module', 'system_test') . '/system_test.module', array(), $page_title);
+  redirect($authorize_url);
 }
diff --git a/core/modules/simpletest/tests/tablesort.test b/core/modules/simpletest/tests/tablesort.test
index 9c068f8..4f9f9d3 100644
--- a/core/modules/simpletest/tests/tablesort.test
+++ b/core/modules/simpletest/tests/tablesort.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -8,7 +9,7 @@
 /**
  * Test unicode handling features implemented in unicode.inc.
  */
-class TableSortTest extends DrupalUnitTestCase {
+class TableSortTest extends UnitTestCase {
 
   /**
    * Storage for initial value of $_GET.
diff --git a/core/modules/simpletest/tests/taxonomy_test.install b/core/modules/simpletest/tests/taxonomy_test.install
index d5c94da..7dd24d5 100644
--- a/core/modules/simpletest/tests/taxonomy_test.install
+++ b/core/modules/simpletest/tests/taxonomy_test.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/simpletest/tests/taxonomy_test.module b/core/modules/simpletest/tests/taxonomy_test.module
index aae13a2..4cc1c6e 100644
--- a/core/modules/simpletest/tests/taxonomy_test.module
+++ b/core/modules/simpletest/tests/taxonomy_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/simpletest/tests/theme.test b/core/modules/simpletest/tests/theme.test
index 9870545..04cb9f9 100644
--- a/core/modules/simpletest/tests/theme.test
+++ b/core/modules/simpletest/tests/theme.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use DOMDocument;
 
 /**
  * @file
@@ -8,7 +10,7 @@
 /**
  * Unit tests for the Theme API.
  */
-class ThemeUnitTest extends DrupalWebTestCase {
+class ThemeUnitTest extends WebTestCase {
   protected $profile = 'testing';
 
   public static function getInfo() {
@@ -97,7 +99,7 @@ class ThemeUnitTest extends DrupalWebTestCase {
     $this->assertNoText('system.base.css', t('The theme\'s .info file is able to override a module CSS file from being added to the page.'));
 
     // Also test with aggregation enabled, simply ensuring no PHP errors are
-    // triggered during drupal_build_css_cache() when a source file doesn't
+    // triggered during build_css_cache() when a source file doesn't
     // exist. Then allow remaining tests to continue with aggregation disabled
     // by default.
     variable_set('preprocess_css', 1);
@@ -118,7 +120,7 @@ class ThemeUnitTest extends DrupalWebTestCase {
 /**
  * Unit tests for theme_table().
  */
-class ThemeTableUnitTest extends DrupalWebTestCase {
+class ThemeTableUnitTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Theme Table',
@@ -134,10 +136,10 @@ class ThemeTableUnitTest extends DrupalWebTestCase {
     $header = array('one', 'two', 'three');
     $rows = array(array(1,2,3), array(4,5,6), array(7,8,9));
     $this->content = theme('table', array('header' => $header, 'rows' => $rows));
-    $js = drupal_add_js();
+    $js = add_js();
     $this->assertTrue(isset($js['core/misc/tableheader.js']), t('tableheader.js was included when $sticky = TRUE.'));
     $this->assertRaw('sticky-enabled',  t('Table has a class of sticky-enabled when $sticky = TRUE.'));
-    drupal_static_reset('drupal_add_js');
+    drupal_static_reset('Drupal\add_js');
   }
 
   /**
@@ -150,10 +152,10 @@ class ThemeTableUnitTest extends DrupalWebTestCase {
     $caption = NULL;
     $colgroups = array();
     $this->content = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes, 'caption' => $caption, 'colgroups' => $colgroups, 'sticky' => FALSE));
-    $js = drupal_add_js();
+    $js = add_js();
     $this->assertFalse(isset($js['core/misc/tableheader.js']), t('tableheader.js was not included because $sticky = FALSE.'));
     $this->assertNoRaw('sticky-enabled',  t('Table does not have a class of sticky-enabled because $sticky = FALSE.'));
-    drupal_static_reset('drupal_add_js');
+    drupal_static_reset('Drupal\add_js');
   }
 
   /**
@@ -178,7 +180,7 @@ class ThemeTableUnitTest extends DrupalWebTestCase {
 /**
  * Tests for common theme functions.
  */
-class ThemeFunctionsTestCase extends DrupalWebTestCase {
+class ThemeFunctionsTestCase extends WebTestCase {
   protected $profile = 'testing';
 
   public static function getInfo() {
@@ -337,14 +339,14 @@ class ThemeFunctionsTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Test the use of drupal_pre_render_links() on a nested array of links.
+   * Test the use of pre_render_links() on a nested array of links.
    */
   function testDrupalPreRenderLinks() {
     // Define the base array to be rendered, containing a variety of different
     // kinds of links.
     $base_array = array(
       '#theme' => 'links',
-      '#pre_render' => array('drupal_pre_render_links'),
+      '#pre_render' => array('pre_render_links'),
       '#links' => array(
         'parent_link' => array(
           'title' => 'Parent link original',
@@ -438,7 +440,7 @@ class ThemeFunctionsTestCase extends DrupalWebTestCase {
 /**
  * Functional test for initialization of the theme system in hook_init().
  */
-class ThemeHookInitUnitTest extends DrupalWebTestCase {
+class ThemeHookInitUnitTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Theme initialization in hook_init()',
@@ -464,7 +466,7 @@ class ThemeHookInitUnitTest extends DrupalWebTestCase {
 /**
  * Tests autocompletion not loading registry.
  */
-class ThemeFastTestCase extends DrupalWebTestCase {
+class ThemeFastTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Theme fast initialization',
@@ -491,7 +493,7 @@ class ThemeFastTestCase extends DrupalWebTestCase {
 /**
  * Unit tests for theme_html_tag().
  */
-class ThemeHtmlTag extends DrupalUnitTestCase {
+class ThemeHtmlTag extends UnitTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Theme HTML Tag',
@@ -517,7 +519,7 @@ class ThemeHtmlTag extends DrupalUnitTestCase {
 /**
  * Functional test for attributes of html.tpl.php.
  */
-class ThemeHtmlTplPhpAttributesTestCase extends DrupalWebTestCase {
+class ThemeHtmlTplPhpAttributesTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'html.tpl.php html and body attributes',
@@ -545,7 +547,7 @@ class ThemeHtmlTplPhpAttributesTestCase extends DrupalWebTestCase {
 /**
  * Tests for the ThemeRegistry class.
  */
-class ThemeRegistryTestCase extends DrupalWebTestCase {
+class ThemeRegistryTestCase extends WebTestCase {
   protected $profile = 'testing';
   public static function getInfo() {
     return array(
diff --git a/core/modules/simpletest/tests/theme_test.module b/core/modules/simpletest/tests/theme_test.module
index 570b72c..e59d27a 100644
--- a/core/modules/simpletest/tests/theme_test.module
+++ b/core/modules/simpletest/tests/theme_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Implements hook_theme().
@@ -18,7 +19,7 @@ function theme_test_theme($existing, $type, $theme, $path) {
  * Implements hook_system_theme_info().
  */
 function theme_test_system_theme_info() {
-  $themes['test_theme'] = drupal_get_path('module', 'theme_test') . '/themes/test_theme/test_theme.info';
+  $themes['test_theme'] = get_path('module', 'theme_test') . '/themes/test_theme/test_theme.info';
   return $themes;
 }
 
@@ -61,7 +62,7 @@ function theme_test_init() {
     // First, force the theme registry to be rebuilt on this page request. This
     // allows us to test a full initialization of the theme system in the code
     // below.
-    drupal_theme_rebuild();
+    theme_rebuild();
     // Next, initialize the theme system by storing themed text in a global
     // variable. We will use this later in theme_test_hook_init_page_callback()
     // to test that even when the theme system is initialized this early, it is
@@ -111,7 +112,7 @@ function _theme_custom_theme() {
 }
 
 /**
- * Page callback, calls drupal_alter().
+ * Page callback, calls alter().
  *
  * This is for testing that the theme can have hook_*_alter() implementations
  * that run during page callback execution, even before theme() is called for
@@ -119,7 +120,7 @@ function _theme_custom_theme() {
  */
 function _theme_test_alter() {
   $data = 'foo';
-  drupal_alter('theme_test_alter', $data);
+  alter('theme_test_alter', $data);
   return "The altered data is $data.";
 }
 
diff --git a/core/modules/simpletest/tests/themes/test_theme/template.php b/core/modules/simpletest/tests/themes/test_theme/template.php
index ef8118a..05ec581 100644
--- a/core/modules/simpletest/tests/themes/test_theme/template.php
+++ b/core/modules/simpletest/tests/themes/test_theme/template.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Tests a theme overriding a suggestion of a base theme hook.
@@ -14,7 +15,7 @@ function test_theme_breadcrumb__suggestion($variables) {
  *
  * The confusing function name here is due to this being an implementation of
  * the alter hook invoked when the 'theme_test' module calls
- * drupal_alter('theme_test_alter').
+ * alter('theme_test_alter').
  */
 function test_theme_theme_test_alter_alter(&$data) {
   $data = 'test_theme_theme_test_alter_alter was invoked';
diff --git a/core/modules/simpletest/tests/unicode.test b/core/modules/simpletest/tests/unicode.test
index 5cadb8a..a19727b 100644
--- a/core/modules/simpletest/tests/unicode.test
+++ b/core/modules/simpletest/tests/unicode.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -8,7 +9,7 @@
 /**
  * Test unicode handling features implemented in unicode.inc.
  */
-class UnicodeUnitTest extends DrupalWebTestCase {
+class UnicodeUnitTest extends WebTestCase {
 
   /**
    * Whether to run the extended version of the tests (including non latin1 characters).
diff --git a/core/modules/simpletest/tests/update.test b/core/modules/simpletest/tests/update.test
index abbab47..adccbb6 100644
--- a/core/modules/simpletest/tests/update.test
+++ b/core/modules/simpletest/tests/update.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -8,7 +9,7 @@
 /**
  * Tests for the update dependency ordering system.
  */
-class UpdateDependencyOrderingTestCase extends DrupalWebTestCase {
+class UpdateDependencyOrderingTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Update dependency ordering',
@@ -19,7 +20,7 @@ class UpdateDependencyOrderingTestCase extends DrupalWebTestCase {
 
   function setUp() {
     parent::setUp('update_test_1', 'update_test_2', 'update_test_3');
-    require_once DRUPAL_ROOT . '/core/includes/update.inc';
+    require_once ROOT . '/core/includes/update.inc';
   }
 
   /**
@@ -58,7 +59,7 @@ class UpdateDependencyOrderingTestCase extends DrupalWebTestCase {
 /**
  * Tests for missing update dependencies.
  */
-class UpdateDependencyMissingTestCase extends DrupalWebTestCase {
+class UpdateDependencyMissingTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Missing update dependencies',
@@ -71,7 +72,7 @@ class UpdateDependencyMissingTestCase extends DrupalWebTestCase {
     // Only install update_test_2.module, even though its updates have a
     // dependency on update_test_3.module.
     parent::setUp('update_test_2');
-    require_once DRUPAL_ROOT . '/core/includes/update.inc';
+    require_once ROOT . '/core/includes/update.inc';
   }
 
   function testMissingUpdate() {
@@ -88,7 +89,7 @@ class UpdateDependencyMissingTestCase extends DrupalWebTestCase {
 /**
  * Tests for the invocation of hook_update_dependencies().
  */
-class UpdateDependencyHookInvocationTestCase extends DrupalWebTestCase {
+class UpdateDependencyHookInvocationTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Update dependency hook invocation',
@@ -99,7 +100,7 @@ class UpdateDependencyHookInvocationTestCase extends DrupalWebTestCase {
 
   function setUp() {
     parent::setUp('update_test_1', 'update_test_2');
-    require_once DRUPAL_ROOT . '/core/includes/update.inc';
+    require_once ROOT . '/core/includes/update.inc';
   }
 
   /**
diff --git a/core/modules/simpletest/tests/update_script_test.install b/core/modules/simpletest/tests/update_script_test.install
index 8af516b..9e1eded 100644
--- a/core/modules/simpletest/tests/update_script_test.install
+++ b/core/modules/simpletest/tests/update_script_test.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/simpletest/tests/update_script_test.module b/core/modules/simpletest/tests/update_script_test.module
index beb5a71..4621ad1 100644
--- a/core/modules/simpletest/tests/update_script_test.module
+++ b/core/modules/simpletest/tests/update_script_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -14,5 +15,5 @@
  * @see UpdateScriptFunctionalTest::testRequirements()
  */
 function update_script_test_flush_caches() {
-  drupal_set_message(t('hook_flush_caches() invoked for update_script_test.module.'));
+  set_message(t('hook_flush_caches() invoked for update_script_test.module.'));
 }
diff --git a/core/modules/simpletest/tests/update_test_1.install b/core/modules/simpletest/tests/update_test_1.install
index 22398a3..2042406 100644
--- a/core/modules/simpletest/tests/update_test_1.install
+++ b/core/modules/simpletest/tests/update_test_1.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/simpletest/tests/update_test_1.module b/core/modules/simpletest/tests/update_test_1.module
index b3d9bbc..66bf2d1 100644
--- a/core/modules/simpletest/tests/update_test_1.module
+++ b/core/modules/simpletest/tests/update_test_1.module
@@ -1 +1,2 @@
 <?php
+namespace Drupal;
diff --git a/core/modules/simpletest/tests/update_test_2.install b/core/modules/simpletest/tests/update_test_2.install
index c73271a..a637ac8 100644
--- a/core/modules/simpletest/tests/update_test_2.install
+++ b/core/modules/simpletest/tests/update_test_2.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/simpletest/tests/update_test_2.module b/core/modules/simpletest/tests/update_test_2.module
index b3d9bbc..66bf2d1 100644
--- a/core/modules/simpletest/tests/update_test_2.module
+++ b/core/modules/simpletest/tests/update_test_2.module
@@ -1 +1,2 @@
 <?php
+namespace Drupal;
diff --git a/core/modules/simpletest/tests/update_test_3.install b/core/modules/simpletest/tests/update_test_3.install
index 96830c8..b92c81a 100644
--- a/core/modules/simpletest/tests/update_test_3.install
+++ b/core/modules/simpletest/tests/update_test_3.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/simpletest/tests/update_test_3.module b/core/modules/simpletest/tests/update_test_3.module
index b3d9bbc..66bf2d1 100644
--- a/core/modules/simpletest/tests/update_test_3.module
+++ b/core/modules/simpletest/tests/update_test_3.module
@@ -1 +1,2 @@
 <?php
+namespace Drupal;
diff --git a/core/modules/simpletest/tests/upgrade/upgrade.test b/core/modules/simpletest/tests/upgrade/upgrade.test
index 29793b2..9f45586 100644
--- a/core/modules/simpletest/tests/upgrade/upgrade.test
+++ b/core/modules/simpletest/tests/upgrade/upgrade.test
@@ -1,9 +1,11 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * Perform end-to-end tests of the upgrade path.
  */
-abstract class UpgradePathTestCase extends DrupalWebTestCase {
+abstract class UpgradePathTestCase extends WebTestCase {
 
   /**
    * The file path(s) to the dumped database(s) to load into the child site.
@@ -40,13 +42,13 @@ abstract class UpgradePathTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Override of DrupalWebTestCase::setUp() specialized for upgrade testing.
+   * Override of WebTestCase::setUp() specialized for upgrade testing.
    */
   protected function setUp() {
     global $user, $language, $conf;
 
     // Load the Update API.
-    require_once DRUPAL_ROOT . '/core/includes/update.inc';
+    require_once ROOT . '/core/includes/update.inc';
 
     // Reset flags.
     $this->upgradedSite = FALSE;
@@ -75,13 +77,13 @@ abstract class UpgradePathTestCase extends DrupalWebTestCase {
     $this->originalLanguage = $language;
     $this->originalLanguageDefault = variable_get('language_default');
     $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files');
-    $this->originalProfile = drupal_get_profile();
+    $this->originalProfile = get_profile();
     $clean_url_original = variable_get('clean_url', 0);
 
     // Unregister the registry.
     // This is required to make sure that the database layer works properly.
-    spl_autoload_unregister('drupal_autoload_class');
-    spl_autoload_unregister('drupal_autoload_interface');
+    spl_autoload_unregister('autoload_class');
+    spl_autoload_unregister('autoload_interface');
 
     // Create test directories ahead of installation so fatal errors and debug
     // information can be logged during installation process.
@@ -121,19 +123,19 @@ abstract class UpgradePathTestCase extends DrupalWebTestCase {
 
     // Load user 1.
     $this->originalUser = $user;
-    drupal_save_session(FALSE);
+    save_session(FALSE);
     $user = db_query('SELECT * FROM {users} WHERE uid = :uid', array(':uid' => 1))->fetchObject();
 
     // Generate and set a D6-compatible session cookie.
     $this->curlInitialize();
-    $sid = drupal_hash_base64(uniqid(mt_rand(), TRUE) . drupal_random_bytes(55));
+    $sid = hash_base64(uniqid(mt_rand(), TRUE) . random_bytes(55));
     curl_setopt($this->curlHandle, CURLOPT_COOKIE, rawurlencode(session_name()) . '=' . rawurlencode($sid));
 
     // Force our way into the session of the child site.
-    drupal_save_session(TRUE);
-    _drupal_session_write($sid, '');
+    save_session(TRUE);
+    _session_write($sid, '');
     // Remove the temporarily added ssid column.
-    drupal_save_session(FALSE);
+    save_session(FALSE);
 
     // Restore necessary variables.
     $this->variable_set('clean_url', $clean_url_original);
@@ -144,7 +146,7 @@ abstract class UpgradePathTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Override of DrupalWebTestCase::tearDown() specialized for upgrade testing.
+   * Override of WebTestCase::tearDown() specialized for upgrade testing.
    */
   protected function tearDown() {
     global $user, $language;
@@ -168,7 +170,7 @@ abstract class UpgradePathTestCase extends DrupalWebTestCase {
 
     // Return the user to the original one.
     $user = $this->originalUser;
-    drupal_save_session(TRUE);
+    save_session(TRUE);
 
     // Ensure that internal logged in variable and cURL options are reset.
     $this->loggedInUser = FALSE;
@@ -293,7 +295,7 @@ abstract class UpgradePathTestCase extends DrupalWebTestCase {
     // but not on the test client, we need to load the code here.
     $new_modules = array_diff(module_list(TRUE), $this->loadedModules);
     foreach ($new_modules as $module) {
-      drupal_load('module', $module);
+      load('module', $module);
     }
 
     // Reload hook implementations
@@ -301,7 +303,7 @@ abstract class UpgradePathTestCase extends DrupalWebTestCase {
 
     // Rebuild caches.
     drupal_static_reset();
-    drupal_flush_all_caches();
+    flush_all_caches();
 
     // Reload global $conf array and permissions.
     $this->refreshVariables();
diff --git a/core/modules/simpletest/tests/upgrade/upgrade_bare.test b/core/modules/simpletest/tests/upgrade/upgrade_bare.test
index f507aea..9f38c8b 100644
--- a/core/modules/simpletest/tests/upgrade/upgrade_bare.test
+++ b/core/modules/simpletest/tests/upgrade/upgrade_bare.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Upgrade test for the bare database..
@@ -17,7 +18,7 @@ class BareUpgradePathTestCase extends UpgradePathTestCase {
   public function setUp() {
     // Path to the database dump.
     $this->databaseDumpFiles = array(
-      drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-7.bare.database.php.gz',
+      get_path('module', 'simpletest') . '/tests/upgrade/drupal-7.bare.database.php.gz',
     );
     parent::setUp();
   }
diff --git a/core/modules/simpletest/tests/upgrade/upgrade_filled.test b/core/modules/simpletest/tests/upgrade/upgrade_filled.test
index 9b17bda..99001d2 100644
--- a/core/modules/simpletest/tests/upgrade/upgrade_filled.test
+++ b/core/modules/simpletest/tests/upgrade/upgrade_filled.test
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Upgrade test for the filled database..
@@ -17,7 +18,7 @@ class FilledUpgradePathTestCase extends UpgradePathTestCase {
   public function setUp() {
     // Path to the database dump.
     $this->databaseDumpFiles = array(
-      drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-7.filled.database.php.gz',
+      get_path('module', 'simpletest') . '/tests/upgrade/drupal-7.filled.database.php.gz',
     );
     parent::setUp();
   }
diff --git a/core/modules/simpletest/tests/url_alter_test.install b/core/modules/simpletest/tests/url_alter_test.install
index 6e09ab5..20ccec5 100644
--- a/core/modules/simpletest/tests/url_alter_test.install
+++ b/core/modules/simpletest/tests/url_alter_test.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Impelement hook_install().
diff --git a/core/modules/simpletest/tests/url_alter_test.module b/core/modules/simpletest/tests/url_alter_test.module
index 9287ff5..6fe3298 100644
--- a/core/modules/simpletest/tests/url_alter_test.module
+++ b/core/modules/simpletest/tests/url_alter_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -31,7 +32,7 @@ function url_alter_test_foo() {
  */
 function url_alter_test_url_inbound_alter(&$path, $original_path, $path_language) {
   if (!request_path() && !empty($_GET['q'])) {
-    drupal_set_message("\$_GET['q'] is non-empty with an empty request path.");
+    set_message("\$_GET['q'] is non-empty with an empty request path.");
   }
 
   // Rewrite user/username to user/uid.
diff --git a/core/modules/simpletest/tests/xmlrpc.test b/core/modules/simpletest/tests/xmlrpc.test
index 60b9624..6ce9494 100644
--- a/core/modules/simpletest/tests/xmlrpc.test
+++ b/core/modules/simpletest/tests/xmlrpc.test
@@ -1,9 +1,10 @@
 <?php
+namespace Drupal;
 
 /**
  * Perform basic XML-RPC tests that do not require addition callbacks.
  */
-class XMLRPCBasicTestCase extends DrupalWebTestCase {
+class XMLRPCBasicTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -80,7 +81,7 @@ class XMLRPCBasicTestCase extends DrupalWebTestCase {
   }
 }
 
-class XMLRPCValidator1IncTestCase extends DrupalWebTestCase {
+class XMLRPCValidator1IncTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'XML-RPC validator',
@@ -194,7 +195,7 @@ class XMLRPCValidator1IncTestCase extends DrupalWebTestCase {
   }
 }
 
-class XMLRPCMessagesTestCase extends DrupalWebTestCase {
+class XMLRPCMessagesTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name'  => 'XML-RPC message and alteration',
diff --git a/core/modules/simpletest/tests/xmlrpc_test.module b/core/modules/simpletest/tests/xmlrpc_test.module
index db8f113..41d1e2d 100644
--- a/core/modules/simpletest/tests/xmlrpc_test.module
+++ b/core/modules/simpletest/tests/xmlrpc_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 function xmlrpc_test_arrayOfStructsTest($array) {
   $sum = 0;
diff --git a/core/modules/statistics/statistics.admin.inc b/core/modules/statistics/statistics.admin.inc
index 6606b8b..2067465 100644
--- a/core/modules/statistics/statistics.admin.inc
+++ b/core/modules/statistics/statistics.admin.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -78,7 +79,7 @@ function statistics_top_pages() {
     $rows[] = array($page->hits, _statistics_format_item($page->title, $page->path), t('%time ms', array('%time' => round($page->average_time))), format_interval(round($page->total_time / 1000)));
   }
 
-  drupal_set_title(t('Top pages in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)))), PASS_THROUGH);
+  set_title(t('Top pages in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)))), PASS_THROUGH);
   $build['statistics_top_pages_table'] = array(
     '#theme' => 'table',
     '#header' => $header,
@@ -125,13 +126,13 @@ function statistics_top_visitors() {
 
   $result = $query->execute();
   $rows = array();
-  $destination = drupal_get_destination();
+  $destination = get_destination();
   foreach ($result as $account) {
     $ban_link = $account->iid ? l(t('unblock IP address'), "admin/config/people/ip-blocking/delete/$account->iid", array('query' => $destination)) : l(t('block IP address'), "admin/config/people/ip-blocking/$account->hostname", array('query' => $destination));
     $rows[] = array($account->hits, ($account->uid ? theme('username', array('account' => $account)) : $account->hostname), format_interval(round($account->total / 1000)), (user_access('block IP addresses') && !$account->uid) ? $ban_link : '');
   }
 
-  drupal_set_title(t('Top visitors in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)))), PASS_THROUGH);
+  set_title(t('Top visitors in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)))), PASS_THROUGH);
   $build['statistics_top_visitors_table'] = array(
     '#theme' => 'table',
     '#header' => $header,
@@ -146,7 +147,7 @@ function statistics_top_visitors() {
  * Menu callback; presents the "referrer" page.
  */
 function statistics_top_referrers() {
-  drupal_set_title(t('Top referrers in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)))), PASS_THROUGH);
+  set_title(t('Top referrers in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)))), PASS_THROUGH);
 
   $header = array(
     array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'),
@@ -199,7 +200,7 @@ function statistics_access_log($aid) {
       l(url($access->path, array('absolute' => TRUE)), $access->path)
     );
     // It is safe to avoid filtering $access->title through check_plain because
-    // it comes from drupal_get_title().
+    // it comes from get_title().
     $rows[] = array(
       array('data' => t('Title'), 'header' => TRUE),
       $access->title
@@ -228,7 +229,7 @@ function statistics_access_log($aid) {
     return $build;
   }
   else {
-    drupal_not_found();
+    not_found();
   }
 }
 
@@ -254,7 +255,7 @@ function statistics_settings_form() {
     '#type' => 'select',
     '#title' => t('Discard access logs older than'),
     '#default_value' => variable_get('statistics_flush_accesslog_timer', 259200),
-    '#options' => array(0 => t('Never')) + drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval'),
+    '#options' => array(0 => t('Never')) + map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval'),
     '#description' => t('Older access log entries (including referrer statistics) will be automatically discarded. (Requires a correctly configured <a href="@cron">cron maintenance task</a>.)', array('@cron' => url('admin/reports/status'))),
   );
 
diff --git a/core/modules/statistics/statistics.install b/core/modules/statistics/statistics.install
index a5dc7f8..23f97f6 100644
--- a/core/modules/statistics/statistics.install
+++ b/core/modules/statistics/statistics.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module
index eda808f..2daf1b0 100644
--- a/core/modules/statistics/statistics.module
+++ b/core/modules/statistics/statistics.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -55,7 +56,7 @@ function statistics_exit() {
   // performance decrease for non-database page caches, but with Statistics
   // module, it is likely to also have 'statistics_enable_access_log' enabled,
   // in which case we need to bootstrap to the session phase anyway.
-  drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);
+  bootstrap(BOOTSTRAP_VARIABLES);
 
   if (variable_get('statistics_count_content_views', 0)) {
     // We are counting content views.
@@ -74,14 +75,14 @@ function statistics_exit() {
     }
   }
   if (variable_get('statistics_enable_access_log', 0)) {
-    drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
+    bootstrap(BOOTSTRAP_SESSION);
 
     // For anonymous users unicode.inc will not have been loaded.
-    include_once DRUPAL_ROOT . '/core/includes/unicode.inc';
+    include_once ROOT . '/core/includes/unicode.inc';
     // Log this page access.
     db_insert('accesslog')
       ->fields(array(
-        'title' => truncate_utf8(strip_tags(drupal_get_title()), 255),
+        'title' => truncate_utf8(strip_tags(get_title()), 255),
         'path' => truncate_utf8($_GET['q'], 255),
         'url' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
         'hostname' => ip_address(),
@@ -175,7 +176,7 @@ function statistics_menu() {
   $items['admin/config/system/statistics'] = array(
     'title' => 'Statistics',
     'description' => 'Control details about what and how your site logs access statistics.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('statistics_settings_form'),
     'access arguments' => array('administer statistics'),
     'file' => 'statistics.admin.inc',
@@ -314,7 +315,7 @@ function statistics_block_info() {
   if (variable_get('statistics_count_content_views', 0)) {
     $blocks['popular']['info'] = t('Popular content');
     // Too dynamic to cache.
-    $blocks['popular']['cache'] = DRUPAL_NO_CACHE;
+    $blocks['popular']['cache'] = NO_CACHE;
   }
   return $blocks;
 }
@@ -324,7 +325,7 @@ function statistics_block_info() {
  */
 function statistics_block_configure($delta = '') {
   // Popular content block settings
-  $numbers = array('0' => t('Disabled')) + drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40));
+  $numbers = array('0' => t('Disabled')) + map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40));
   $form['statistics_block_top_day_num'] = array('#type' => 'select', '#title' => t("Number of day's top views to display"), '#default_value' => variable_get('statistics_block_top_day_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "day" list.'));
   $form['statistics_block_top_all_num'] = array('#type' => 'select', '#title' => t('Number of all time views to display'), '#default_value' => variable_get('statistics_block_top_all_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "all time" list.'));
   $form['statistics_block_top_last_num'] = array('#type' => 'select', '#title' => t('Number of most recent views to display'), '#default_value' => variable_get('statistics_block_top_last_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "recently viewed" list.'));
@@ -378,7 +379,7 @@ function statistics_block_view($delta = '') {
  * statistics module.
  */
 function _statistics_link($path, $width = 35) {
-  $title = drupal_get_path_alias($path);
+  $title = get_path_alias($path);
   $title = truncate_utf8($title, $width, FALSE, TRUE);
   return l($title, $path);
 }
diff --git a/core/modules/statistics/statistics.pages.inc b/core/modules/statistics/statistics.pages.inc
index 1d91609..0bcc141 100644
--- a/core/modules/statistics/statistics.pages.inc
+++ b/core/modules/statistics/statistics.pages.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -37,7 +38,7 @@ function statistics_node_tracker() {
       );
     }
 
-    drupal_set_title($node->title);
+    set_title($node->title);
     $build['statistics_table'] = array(
       '#theme' => 'table',
       '#header' => $header,
@@ -48,7 +49,7 @@ function statistics_node_tracker() {
     return $build;
   }
   else {
-    drupal_not_found();
+    not_found();
   }
 }
 
@@ -75,7 +76,7 @@ function statistics_user_tracker() {
         l(t('details'), "admin/reports/access/$log->aid"));
     }
 
-    drupal_set_title(user_format_name($account));
+    set_title(user_format_name($account));
     $build['statistics_table'] = array(
       '#theme' => 'table',
       '#header' => $header,
@@ -86,6 +87,6 @@ function statistics_user_tracker() {
     return $build;
   }
   else {
-    drupal_not_found();
+    not_found();
   }
 }
diff --git a/core/modules/statistics/statistics.test b/core/modules/statistics/statistics.test
index 592f165..aa1df76 100644
--- a/core/modules/statistics/statistics.test
+++ b/core/modules/statistics/statistics.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use PDO;
 
 /**
  * @file
@@ -8,7 +10,7 @@
 /**
  * Sets up a base class for the Statistics module.
  */
-class StatisticsTestCase extends DrupalWebTestCase {
+class StatisticsTestCase extends WebTestCase {
 
   function setUp() {
     parent::setUp('statistics');
@@ -48,10 +50,10 @@ class StatisticsTestCase extends DrupalWebTestCase {
 /**
  * Tests that logging via statistics_exit() works for cached and uncached pages.
  *
- * Subclass DrupalWebTestCase rather than StatisticsTestCase, because we want
+ * Subclass WebTestCase rather than StatisticsTestCase, because we want
  * to test requests from an anonymous user.
  */
-class StatisticsLoggingTestCase extends DrupalWebTestCase {
+class StatisticsLoggingTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Statistics logging tests',
@@ -218,7 +220,7 @@ class StatisticsReportsTestCase extends StatisticsTestCase {
     $block->visibility = 0;
     $edit = array('statistics_block_top_day_num' => 3, 'statistics_block_top_all_num' => 3, 'statistics_block_top_last_num' => 3);
     module_invoke('statistics', 'block_save', 'popular', $edit);
-    drupal_write_record('block', $block);
+    write_record('block', $block);
 
     // Get some page and check if the block is displayed.
     $this->drupalGet('user');
@@ -284,7 +286,7 @@ class StatisticsBlockVisitorsTestCase extends StatisticsTestCase {
 /**
  * Test statistics administration screen.
  */
-class StatisticsAdminTestCase extends DrupalWebTestCase {
+class StatisticsAdminTestCase extends WebTestCase {
   protected $privileged_user;
   protected $test_node;
 
diff --git a/core/modules/statistics/statistics.tokens.inc b/core/modules/statistics/statistics.tokens.inc
index c2c8fc3..61bd048 100644
--- a/core/modules/statistics/statistics.tokens.inc
+++ b/core/modules/statistics/statistics.tokens.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/syslog/syslog.install b/core/modules/syslog/syslog.install
index 12ff4fb..3af9e03 100644
--- a/core/modules/syslog/syslog.install
+++ b/core/modules/syslog/syslog.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/syslog/syslog.module b/core/modules/syslog/syslog.module
index 7c7bf40..b4e279f 100644
--- a/core/modules/syslog/syslog.module
+++ b/core/modules/syslog/syslog.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/syslog/syslog.test b/core/modules/syslog/syslog.test
index 691fb7d..c4ad6f4 100644
--- a/core/modules/syslog/syslog.test
+++ b/core/modules/syslog/syslog.test
@@ -1,11 +1,12 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
  * Tests for syslog.module.
  */
 
-class SyslogTestCase extends DrupalWebTestCase {
+class SyslogTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Syslog functionality',
diff --git a/core/modules/system/html.tpl.php b/core/modules/system/html.tpl.php
index 960eefb..291f5fe 100644
--- a/core/modules/system/html.tpl.php
+++ b/core/modules/system/html.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/system/image.gd.inc b/core/modules/system/image.gd.inc
index 39f86dc..50b5302 100644
--- a/core/modules/system/image.gd.inc
+++ b/core/modules/system/image.gd.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
diff --git a/core/modules/system/maintenance-page.tpl.php b/core/modules/system/maintenance-page.tpl.php
index 5cde0ff..ce444d7 100644
--- a/core/modules/system/maintenance-page.tpl.php
+++ b/core/modules/system/maintenance-page.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/system/page.tpl.php b/core/modules/system/page.tpl.php
index c76e27f..9caaacd 100644
--- a/core/modules/system/page.tpl.php
+++ b/core/modules/system/page.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/system/region.tpl.php b/core/modules/system/region.tpl.php
index b29e24f..6ed516b 100644
--- a/core/modules/system/region.tpl.php
+++ b/core/modules/system/region.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc
index 1312af2..6b1a388 100644
--- a/core/modules/system/system.admin.inc
+++ b/core/modules/system/system.admin.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use PDO, stdClass;
 
 /**
  * @file
@@ -11,7 +13,7 @@
 function system_admin_config_page() {
   // Check for status report errors.
   if (system_status(TRUE) && user_access('administer site configuration')) {
-    drupal_set_message(t('One or more problems were detected with your Drupal installation. Check the <a href="@status">status report</a> for more information.', array('@status' => url('admin/reports/status'))), 'error');
+    set_message(t('One or more problems were detected with your Drupal installation. Check the <a href="@status">status report</a> for more information.', array('@status' => url('admin/reports/status'))), 'error');
   }
   $blocks = array();
   if ($admin = db_query("SELECT menu_name, mlid FROM {menu_links} WHERE link_path = 'admin/config' AND module = 'system'")->fetchAssoc()) {
@@ -83,14 +85,14 @@ function system_admin_index() {
     $module_info[$module] = new stdClass();
     $module_info[$module]->info = $info;
   }
-  uasort($module_info, 'system_sort_modules_by_info_name');
+  uasort($module_info, 'Drupal\system_sort_modules_by_info_name');
   $menu_items = array();
 
   foreach ($module_info as $module => $info) {
     // Only display a section if there are any available tasks.
     if ($admin_tasks = system_get_module_admin_tasks($module, $info->info)) {
       // Sort links by title.
-      uasort($admin_tasks, 'drupal_sort_title');
+      uasort($admin_tasks, 'Drupal\sort_title');
       // Move 'Configure permissions' links to the bottom of each section.
       $permission_key = "admin/people/permissions#module-$module";
       if (isset($admin_tasks[$permission_key])) {
@@ -110,7 +112,7 @@ function system_admin_index() {
  */
 function system_settings_overview() {
   // Check database setup if necessary
-  if (function_exists('db_check_setup') && empty($_POST)) {
+  if (function_exists('Drupal\db_check_setup') && empty($_POST)) {
     db_check_setup();
   }
 
@@ -128,7 +130,7 @@ function system_settings_overview() {
 function system_themes_page() {
   // Get current list of themes.
   $themes = system_rebuild_theme_data();
-  uasort($themes, 'system_sort_modules_by_info_name');
+  uasort($themes, 'Drupal\system_sort_modules_by_info_name');
 
   $theme_default = variable_get('theme_default', 'stark');
   $theme_groups  = array();
@@ -167,15 +169,15 @@ function system_themes_page() {
      // Ensure this theme is compatible with this version of core.
      // Require the 'content' region to make sure the main page
      // content has a common place in all themes.
-      $theme->incompatible_core = !isset($theme->info['core']) || ($theme->info['core'] != DRUPAL_CORE_COMPATIBILITY) || (!isset($theme->info['regions']['content']));
+      $theme->incompatible_core = !isset($theme->info['core']) || ($theme->info['core'] != CORE_COMPATIBILITY) || (!isset($theme->info['regions']['content']));
       $theme->incompatible_php = version_compare(phpversion(), $theme->info['php']) < 0;
     }
-    $query['token'] = drupal_get_token('system-theme-operation-link');
+    $query['token'] = get_token('system-theme-operation-link');
     $theme->operations = array();
     if (!empty($theme->status) || !$theme->incompatible_core && !$theme->incompatible_php) {
       // Create the operations links.
       $query['theme'] = $theme->name;
-      if (drupal_theme_access($theme)) {
+      if (theme_access($theme)) {
         $theme->operations[] = array(
           'title' => t('Settings'),
           'href' => 'admin/appearance/settings/' . $theme->name,
@@ -234,10 +236,10 @@ function system_themes_page() {
     $theme_group_titles['disabled'] = format_plural(count($theme_groups['disabled']), 'Disabled theme', 'Disabled themes');
   }
 
-  uasort($theme_groups['enabled'], 'system_sort_themes');
-  drupal_alter('system_themes_page', $theme_groups);
+  uasort($theme_groups['enabled'], 'Drupal\system_sort_themes');
+  alter('system_themes_page', $theme_groups);
 
-  $admin_form = drupal_get_form('system_themes_admin_form', $admin_theme_options);
+  $admin_form = get_form('system_themes_admin_form', $admin_theme_options);
   return theme('system_themes_page', array('theme_groups' => $theme_groups, 'theme_group_titles' => $theme_group_titles)) . drupal_render($admin_form);
 }
 
@@ -272,7 +274,7 @@ function system_themes_admin_form($form, &$form_state, $theme_options) {
  * Process system_themes_admin_form form submissions.
  */
 function system_themes_admin_form_submit($form, &$form_state) {
-  drupal_set_message(t('The configuration options have been saved.'));
+  set_message(t('The configuration options have been saved.'));
   variable_set('admin_theme', $form_state['values']['admin_theme']);
 }
 
@@ -280,7 +282,7 @@ function system_themes_admin_form_submit($form, &$form_state) {
  * Menu callback; Enables a theme.
  */
 function system_theme_enable() {
-  if (isset($_REQUEST['theme']) && isset($_REQUEST['token']) && drupal_valid_token($_REQUEST['token'], 'system-theme-operation-link')) {
+  if (isset($_REQUEST['theme']) && isset($_REQUEST['token']) && valid_token($_REQUEST['token'], 'system-theme-operation-link')) {
     $theme = $_REQUEST['theme'];
     // Get current list of themes.
     $themes = list_themes();
@@ -288,21 +290,21 @@ function system_theme_enable() {
     // Check if the specified theme is one recognized by the system.
     if (!empty($themes[$theme])) {
       theme_enable(array($theme));
-      drupal_set_message(t('The %theme theme has been enabled.', array('%theme' => $themes[$theme]->info['name'])));
+      set_message(t('The %theme theme has been enabled.', array('%theme' => $themes[$theme]->info['name'])));
     }
     else {
-      drupal_set_message(t('The %theme theme was not found.', array('%theme' => $theme)), 'error');
+      set_message(t('The %theme theme was not found.', array('%theme' => $theme)), 'error');
     }
-    drupal_goto('admin/appearance');
+    redirect('admin/appearance');
   }
-  return drupal_access_denied();
+  return access_denied();
 }
 
 /**
  * Menu callback; Disables a theme.
  */
 function system_theme_disable() {
-  if (isset($_REQUEST['theme']) && isset($_REQUEST['token']) && drupal_valid_token($_REQUEST['token'], 'system-theme-operation-link')) {
+  if (isset($_REQUEST['theme']) && isset($_REQUEST['token']) && valid_token($_REQUEST['token'], 'system-theme-operation-link')) {
     $theme = $_REQUEST['theme'];
     // Get current list of themes.
     $themes = list_themes();
@@ -311,26 +313,26 @@ function system_theme_disable() {
     if (!empty($themes[$theme])) {
       if ($theme == variable_get('theme_default', 'stark')) {
         // Don't disable the default theme.
-        drupal_set_message(t('%theme is the default theme and cannot be disabled.', array('%theme' => $themes[$theme]->info['name'])), 'error');
+        set_message(t('%theme is the default theme and cannot be disabled.', array('%theme' => $themes[$theme]->info['name'])), 'error');
       }
       else {
         theme_disable(array($theme));
-        drupal_set_message(t('The %theme theme has been disabled.', array('%theme' => $themes[$theme]->info['name'])));
+        set_message(t('The %theme theme has been disabled.', array('%theme' => $themes[$theme]->info['name'])));
       }
     }
     else {
-      drupal_set_message(t('The %theme theme was not found.', array('%theme' => $theme)), 'error');
+      set_message(t('The %theme theme was not found.', array('%theme' => $theme)), 'error');
     }
-    drupal_goto('admin/appearance');
+    redirect('admin/appearance');
   }
-  return drupal_access_denied();
+  return access_denied();
 }
 
 /**
  * Menu callback; Set the default theme.
  */
 function system_theme_default() {
-  if (isset($_REQUEST['theme']) && isset($_REQUEST['token']) && drupal_valid_token($_REQUEST['token'], 'system-theme-operation-link')) {
+  if (isset($_REQUEST['theme']) && isset($_REQUEST['token']) && valid_token($_REQUEST['token'], 'system-theme-operation-link')) {
     $theme = $_REQUEST['theme'];
     // Get current list of themes.
     $themes = list_themes();
@@ -355,21 +357,21 @@ function system_theme_default() {
       // a value of 0 means the admin theme is set to be the default theme.
       $admin_theme = variable_get('admin_theme', 0);
       if ($admin_theme != 0 && $admin_theme != $theme) {
-        drupal_set_message(t('Please note that the administration theme is still set to the %admin_theme theme; consequently, the theme on this page remains unchanged. All non-administrative sections of the site, however, will show the selected %selected_theme theme by default.', array(
+        set_message(t('Please note that the administration theme is still set to the %admin_theme theme; consequently, the theme on this page remains unchanged. All non-administrative sections of the site, however, will show the selected %selected_theme theme by default.', array(
           '%admin_theme' => $themes[$admin_theme]->info['name'],
           '%selected_theme' => $themes[$theme]->info['name'],
         )));
       }
       else {
-        drupal_set_message(t('%theme is now the default theme.', array('%theme' => $themes[$theme]->info['name'])));
+        set_message(t('%theme is now the default theme.', array('%theme' => $themes[$theme]->info['name'])));
       }
     }
     else {
-      drupal_set_message(t('The %theme theme was not found.', array('%theme' => $theme)), 'error');
+      set_message(t('The %theme theme was not found.', array('%theme' => $theme)), 'error');
     }
-    drupal_goto('admin/appearance');
+    redirect('admin/appearance');
   }
-  return drupal_access_denied();
+  return access_denied();
 }
 
 /**
@@ -526,7 +528,7 @@ function system_theme_settings($form, &$form_state, $key = '') {
 
   if ($key) {
     // Call engine-specific settings.
-    $function = $themes[$key]->prefix . '_engine_settings';
+    $function = 'Drupal\\' . $themes[$key]->prefix . '_engine_settings';
     if (function_exists($function)) {
       $form['engine_specific'] = array(
         '#type' => 'fieldset',
@@ -554,13 +556,13 @@ function system_theme_settings($form, &$form_state, $key = '') {
     // Process the theme and all its base themes.
     foreach ($theme_keys as $theme) {
       // Include the theme-settings.php file.
-      $filename = DRUPAL_ROOT . '/' . str_replace("/$theme.info", '', $themes[$theme]->filename) . '/theme-settings.php';
+      $filename = ROOT . '/' . str_replace("/$theme.info", '', $themes[$theme]->filename) . '/theme-settings.php';
       if (file_exists($filename)) {
         require_once $filename;
       }
 
       // Call theme-specific settings.
-      $function = $theme . '_form_system_theme_settings_alter';
+      $function = 'Drupal\\' . $theme . '_form_system_theme_settings_alter';
       if (function_exists($function)) {
         $function($form, $form_state);
       }
@@ -704,7 +706,7 @@ function system_theme_settings_submit($form, &$form_state) {
   }
 
   variable_set($key, $values);
-  drupal_set_message(t('The configuration options have been saved.'));
+  set_message(t('The configuration options have been saved.'));
 
   cache_clear_all();
 }
@@ -741,7 +743,7 @@ function _system_is_incompatible(&$incompatible, $files, $file) {
  *
  * The list of modules gets populated by module.info files, which contain each
  * module's name, description, and information about which modules it requires.
- * See drupal_parse_info_file() for information on module.info descriptors.
+ * See parse_info_file() for information on module.info descriptors.
  *
  * Dependency checking is performed to ensure that a module:
  * - can not be enabled if there are disabled modules it requires.
@@ -769,7 +771,7 @@ function system_modules($form, $form_state = array()) {
     }
   }
 
-  uasort($visible_files, 'system_sort_modules_by_info_name');
+  uasort($visible_files, 'Drupal\system_sort_modules_by_info_name');
 
   // If the modules form was submitted, then system_modules_submit() runs first
   // and if there are unfilled required modules, then $form_state['storage'] is
@@ -783,11 +785,11 @@ function system_modules($form, $form_state = array()) {
   $form['modules'] = array('#tree' => TRUE);
 
   // Used when checking if module implements a help page.
-  $help_arg = module_exists('help') ? drupal_help_arg() : FALSE;
+  $help_arg = module_exists('help') ? help_arg() : FALSE;
 
   // Used when displaying modules that are required by the install profile.
-  require_once DRUPAL_ROOT . '/core/includes/install.inc';
-  $distribution_name = check_plain(drupal_install_profile_distribution_name());
+  require_once ROOT . '/core/includes/install.inc';
+  $distribution_name = check_plain(install_profile_distribution_name());
 
   // Iterate through each of the modules.
   foreach ($visible_files as $filename => $module) {
@@ -808,7 +810,7 @@ function system_modules($form, $form_state = array()) {
       elseif (isset($visible_files[$requires])) {
         $requires_name = $files[$requires]->info['name'];
         // Disable this module if it is incompatible with the dependency's version.
-        if ($incompatible_version = drupal_check_incompatibility($v, str_replace(DRUPAL_CORE_COMPATIBILITY . '-', '', $files[$requires]->info['version']))) {
+        if ($incompatible_version = check_incompatibility($v, str_replace(CORE_COMPATIBILITY . '-', '', $files[$requires]->info['version']))) {
           $extra['requires'][$requires] = t('@module (<span class="admin-missing">incompatible with</span> version @version)', array(
             '@module' => $requires_name . $incompatible_version,
             '@version' => $files[$requires]->info['version'],
@@ -817,7 +819,7 @@ function system_modules($form, $form_state = array()) {
         }
         // Disable this module if the dependency is incompatible with this
         // version of Drupal core.
-        elseif ($files[$requires]->info['core'] != DRUPAL_CORE_COMPATIBILITY) {
+        elseif ($files[$requires]->info['core'] != CORE_COMPATIBILITY) {
           $extra['requires'][$requires] = t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', array(
             '@module' => $requires_name,
           ));
@@ -902,7 +904,7 @@ function system_modules($form, $form_state = array()) {
   }
 
   // Lastly, sort all fieldsets by title.
-  uasort($form['modules'], 'element_sort_by_title');
+  uasort($form['modules'], 'Drupal\element_sort_by_title');
 
   $form['actions'] = array('#type' => 'actions');
   $form['actions']['submit'] = array(
@@ -968,10 +970,10 @@ function _system_modules_build_row($info, $extra) {
   $status_long = '';
 
   // Check the core compatibility.
-  if (!isset($info['core']) || $info['core'] != DRUPAL_CORE_COMPATIBILITY) {
+  if (!isset($info['core']) || $info['core'] != CORE_COMPATIBILITY) {
     $compatible = FALSE;
     $status_short .= t('Incompatible with this version of Drupal core.');
-    $status_long .= t('This version is not compatible with Drupal !core_version and should be replaced.', array('!core_version' => DRUPAL_CORE_COMPATIBILITY));
+    $status_long .= t('This version is not compatible with Drupal !core_version and should be replaced.', array('!core_version' => CORE_COMPATIBILITY));
   }
 
   // Ensure this module is compatible with the currently installed version of PHP.
@@ -1064,7 +1066,7 @@ function system_modules_confirm_form($modules, $storage) {
  * Submit callback; handles modules form submission.
  */
 function system_modules_submit($form, &$form_state) {
-  include_once DRUPAL_ROOT . '/core/includes/install.inc';
+  include_once ROOT . '/core/includes/install.inc';
 
   // Builds list of modules.
   $modules = array();
@@ -1140,8 +1142,8 @@ function system_modules_submit($form, &$form_state) {
   // the dependent modules aren't installed either.
   foreach ($modules as $name => $module) {
     // Only invoke hook_requirements() on modules that are going to be installed.
-    if ($module['enabled'] && drupal_get_installed_schema_version($name) == SCHEMA_UNINSTALLED) {
-      if (!drupal_check_module($name)) {
+    if ($module['enabled'] && get_installed_schema_version($name) == SCHEMA_UNINSTALLED) {
+      if (!check_module($name)) {
         $modules[$name]['enabled'] = FALSE;
         foreach (array_keys($files[$name]->required_by) as $required_by) {
           $modules[$required_by]['enabled'] = FALSE;
@@ -1160,7 +1162,7 @@ function system_modules_submit($form, &$form_state) {
   // Builds arrays of modules that need to be enabled, disabled, and installed.
   foreach ($modules as $name => $module) {
     if ($module['enabled']) {
-      if (drupal_get_installed_schema_version($name) == SCHEMA_UNINSTALLED) {
+      if (get_installed_schema_version($name) == SCHEMA_UNINSTALLED) {
         $actions['install'][] = $name;
         $actions['enable'][] = $name;
       }
@@ -1189,8 +1191,8 @@ function system_modules_submit($form, &$form_state) {
   // message if there are changes.
   $post_install_list = module_list(TRUE);
   if ($pre_install_list != $post_install_list) {
-    drupal_flush_all_caches();
-    drupal_set_message(t('The configuration options have been saved.'));
+    flush_all_caches();
+    set_message(t('The configuration options have been saved.'));
   }
 
   $form_state['redirect'] = 'admin/modules';
@@ -1213,7 +1215,7 @@ function system_modules_submit($form, &$form_state) {
  */
 function system_modules_uninstall($form, $form_state = NULL) {
   // Make sure the install API is available.
-  include_once DRUPAL_ROOT . '/core/includes/install.inc';
+  include_once ROOT . '/core/includes/install.inc';
 
   // Display the confirm form if any modules have been submitted.
   if (!empty($form_state['storage']) && $confirm_form = system_modules_uninstall_confirm_form($form_state['storage'])) {
@@ -1232,8 +1234,8 @@ function system_modules_uninstall($form, $form_state = NULL) {
   // Only build the rest of the form if there are any modules available to
   // uninstall.
   if (!empty($disabled_modules)) {
-    $profile = drupal_get_profile();
-    uasort($disabled_modules, 'system_sort_modules_by_info_name');
+    $profile = get_profile();
+    uasort($disabled_modules, 'Drupal\system_sort_modules_by_info_name');
     $form['uninstall'] = array('#tree' => TRUE);
     foreach ($disabled_modules as $module) {
       $module_name = $module->info['name'] ? $module->info['name'] : $module->name;
@@ -1249,7 +1251,7 @@ function system_modules_uninstall($form, $form_state = NULL) {
       // we can allow this module to be uninstalled. (The install profile is
       // excluded from this list.)
       foreach (array_keys($module->required_by) as $dependent) {
-        if ($dependent != $profile && drupal_get_installed_schema_version($dependent) != SCHEMA_UNINSTALLED) {
+        if ($dependent != $profile && get_installed_schema_version($dependent) != SCHEMA_UNINSTALLED) {
           $dependent_name = isset($all_modules[$dependent]->info['name']) ? $all_modules[$dependent]->info['name'] : $dependent;
           $form['modules'][$module->name]['#required_by'][] = $dependent_name;
           $form['uninstall'][$module->name]['#disabled'] = TRUE;
@@ -1287,7 +1289,7 @@ function system_modules_uninstall_confirm_form($storage) {
 
   // Construct the hidden form elements and list items.
   foreach (array_filter($storage['uninstall']) as $module => $value) {
-    $info = drupal_parse_info_file(drupal_get_path('module', $module) . '/' . $module . '.info');
+    $info = parse_info_file(get_path('module', $module) . '/' . $module . '.info');
     $uninstall[] = $info['name'];
     $form['uninstall'][$module] = array('#type' => 'hidden',
       '#value' => 1,
@@ -1316,8 +1318,8 @@ function system_modules_uninstall_confirm_form($storage) {
 function system_modules_uninstall_validate($form, &$form_state) {
   // Form submitted, but no modules selected.
   if (!count(array_filter($form_state['values']['uninstall']))) {
-    drupal_set_message(t('No modules selected.'), 'error');
-    drupal_goto('admin/modules/uninstall');
+    set_message(t('No modules selected.'), 'error');
+    redirect('admin/modules/uninstall');
   }
 }
 
@@ -1326,13 +1328,13 @@ function system_modules_uninstall_validate($form, &$form_state) {
  */
 function system_modules_uninstall_submit($form, &$form_state) {
   // Make sure the install API is available.
-  include_once DRUPAL_ROOT . '/core/includes/install.inc';
+  include_once ROOT . '/core/includes/install.inc';
 
   if (!empty($form['#confirmed'])) {
     // Call the uninstall routine for each selected module.
     $modules = array_keys($form_state['values']['uninstall']);
-    drupal_uninstall_modules($modules);
-    drupal_set_message(t('The selected modules have been uninstalled.'));
+    uninstall_modules($modules);
+    set_message(t('The selected modules have been uninstalled.'));
 
     $form_state['redirect'] = 'admin/modules/uninstall';
   }
@@ -1346,7 +1348,7 @@ function system_modules_uninstall_submit($form, &$form_state) {
  * Menu callback. Display blocked IP addresses.
  *
  * @param $default_ip
- *   Optional IP address to be passed on to drupal_get_form() for
+ *   Optional IP address to be passed on to get_form() for
  *   use as the default value of the IP address form field.
  */
 function system_ip_blocking($default_ip = '') {
@@ -1360,7 +1362,7 @@ function system_ip_blocking($default_ip = '') {
     );
   }
 
-  $build['system_ip_blocking_form'] = drupal_get_form('system_ip_blocking_form', $default_ip);
+  $build['system_ip_blocking_form'] = get_form('system_ip_blocking_form', $default_ip);
 
   $build['system_ip_blocking_table'] = array(
     '#theme' => 'table',
@@ -1415,7 +1417,7 @@ function system_ip_blocking_form_submit($form, &$form_state) {
   db_insert('blocked_ips')
     ->fields(array('ip' => $ip))
     ->execute();
-  drupal_set_message(t('The IP address %ip has been blocked.', array('%ip' => $ip)));
+  set_message(t('The IP address %ip has been blocked.', array('%ip' => $ip)));
   $form_state['redirect'] = 'admin/config/people/ip-blocking';
   return;
 }
@@ -1442,7 +1444,7 @@ function system_ip_blocking_delete_submit($form, &$form_state) {
     ->condition('iid', $blocked_ip['iid'])
     ->execute();
   watchdog('user', 'Deleted %ip', array('%ip' => $blocked_ip['ip']));
-  drupal_set_message(t('The IP address %ip was deleted.', array('%ip' => $blocked_ip['ip'])));
+  set_message(t('The IP address %ip was deleted.', array('%ip' => $blocked_ip['ip'])));
   $form_state['redirect'] = 'admin/config/people/ip-blocking';
 }
 
@@ -1483,7 +1485,7 @@ function system_site_information_settings() {
   $form['front_page']['site_frontpage'] = array(
     '#type' => 'textfield',
     '#title' => t('Default front page'),
-    '#default_value' => (variable_get('site_frontpage') != 'user' ? drupal_get_path_alias(variable_get('site_frontpage', 'user')) : ''),
+    '#default_value' => (variable_get('site_frontpage') != 'user' ? get_path_alias(variable_get('site_frontpage', 'user')) : ''),
     '#size' => 40,
     '#description' => t('Optionally, specify a relative URL to display as the front page.  Leave blank to display the default content feed.'),
     '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
@@ -1491,7 +1493,7 @@ function system_site_information_settings() {
   $form['front_page']['default_nodes_main'] = array(
     '#type' => 'select', '#title' => t('Number of posts on front page'),
     '#default_value' => variable_get('default_nodes_main', 10),
-    '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
+    '#options' => map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
     '#description' => t('The maximum number of posts displayed on overview pages such as the front page.'),
     '#access' => (variable_get('site_frontpage') == 'node'),
   );
@@ -1536,25 +1538,25 @@ function system_site_information_settings_validate($form, &$form_state) {
   }
   else {
     // Get the normal path of the front page.
-    form_set_value($form['front_page']['site_frontpage'], drupal_get_normal_path($form_state['values']['site_frontpage']), $form_state);
+    form_set_value($form['front_page']['site_frontpage'], get_normal_path($form_state['values']['site_frontpage']), $form_state);
   }
   // Validate front page path.
-  if (!drupal_valid_path($form_state['values']['site_frontpage'])) {
+  if (!valid_path($form_state['values']['site_frontpage'])) {
     form_set_error('site_frontpage', t("The path '%path' is either invalid or you do not have access to it.", array('%path' => $form_state['values']['site_frontpage'])));
   }
   // Get the normal paths of both error pages.
   if (!empty($form_state['values']['site_403'])) {
-    form_set_value($form['error_page']['site_403'], drupal_get_normal_path($form_state['values']['site_403']), $form_state);
+    form_set_value($form['error_page']['site_403'], get_normal_path($form_state['values']['site_403']), $form_state);
   }
   if (!empty($form_state['values']['site_404'])) {
-    form_set_value($form['error_page']['site_404'], drupal_get_normal_path($form_state['values']['site_404']), $form_state);
+    form_set_value($form['error_page']['site_404'], get_normal_path($form_state['values']['site_404']), $form_state);
   }
   // Validate 403 error path.
-  if (!empty($form_state['values']['site_403']) && !drupal_valid_path($form_state['values']['site_403'])) {
+  if (!empty($form_state['values']['site_403']) && !valid_path($form_state['values']['site_403'])) {
     form_set_error('site_403', t("The path '%path' is either invalid or you do not have access to it.", array('%path' => $form_state['values']['site_403'])));
   }
   // Validate 404 error path.
-  if (!empty($form_state['values']['site_404']) && !drupal_valid_path($form_state['values']['site_404'])) {
+  if (!empty($form_state['values']['site_404']) && !valid_path($form_state['values']['site_404'])) {
     form_set_error('site_404', t("The path '%path' is either invalid or you do not have access to it.", array('%path' => $form_state['values']['site_404'])));
   }
 }
@@ -1584,8 +1586,8 @@ function system_cron_settings() {
   $form['cron']['cron_safe_threshold'] = array(
     '#type' => 'select',
     '#title' => t('Run cron every'),
-    '#default_value' => variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD),
-    '#options' => array(0 => t('Never')) + drupal_map_assoc(array(3600, 10800, 21600, 43200, 86400, 604800), 'format_interval'),
+    '#default_value' => variable_get('cron_safe_threshold', CRON_DEFAULT_THRESHOLD),
+    '#options' => array(0 => t('Never')) + map_assoc(array(3600, 10800, 21600, 43200, 86400, 604800), 'Drupal\format_interval'),
   );
 
   return system_settings_form($form);
@@ -1598,14 +1600,14 @@ function system_cron_settings() {
  */
 function system_run_cron_submit($form, &$form_state) {
   // Run cron manually from Cron form.
-  if (drupal_cron_run()) {
-    drupal_set_message(t('Cron run successfully.'));
+  if (cron_run()) {
+    set_message(t('Cron run successfully.'));
   }
   else {
-    drupal_set_message(t('Cron run failed.'), 'error');
+    set_message(t('Cron run failed.'), 'error');
   }
 
-  drupal_goto('admin/config/system/cron');
+  redirect('admin/config/system/cron');
 }
 
 /**
@@ -1637,7 +1639,7 @@ function system_logging_settings() {
  * @see system_settings_form()
  */
 function system_performance_settings() {
-  drupal_add_js(drupal_get_path('module', 'system') . '/system.js');
+  add_js(get_path('module', 'system') . '/system.js');
 
   $form['clear_cache'] = array(
     '#type' => 'fieldset',
@@ -1662,7 +1664,7 @@ function system_performance_settings() {
     '#default_value' => $cache,
     '#weight' => -2,
   );
-  $period = drupal_map_assoc(array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400), 'format_interval');
+  $period = map_assoc(array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400), 'Drupal\format_interval');
   $period[0] = '<' . t('none') . '>';
   $form['caching']['cache_lifetime'] = array(
     '#type' => 'select',
@@ -1714,8 +1716,8 @@ function system_performance_settings() {
     '#disabled' => $disabled,
   );
 
-  $form['#submit'][] = 'drupal_clear_css_cache';
-  $form['#submit'][] = 'drupal_clear_js_cache';
+  $form['#submit'][] = 'clear_css_cache';
+  $form['#submit'][] = 'clear_js_cache';
   // This form allows page compression settings to be changed, which can
   // invalidate the page cache, so it needs to be cleared on form submit.
   $form['#submit'][] = 'system_clear_page_cache_submit';
@@ -1729,8 +1731,8 @@ function system_performance_settings() {
  * @ingroup forms
  */
 function system_clear_cache_submit($form, &$form_state) {
-  drupal_flush_all_caches();
-  drupal_set_message(t('Caches cleared.'));
+  flush_all_caches();
+  set_message(t('Caches cleared.'));
 }
 
 /**
@@ -1825,7 +1827,7 @@ function system_image_toolkit_settings() {
   }
 
   // Get the toolkit's settings form.
-  $function = 'image_' . $current_toolkit . '_settings';
+  $function = 'Drupal\image_' . $current_toolkit . '_settings';
   if (function_exists($function)) {
     $form['image_toolkit_settings'] = $function();
   }
@@ -1850,7 +1852,7 @@ function system_rss_feeds_settings() {
     '#type' => 'select',
     '#title' => t('Number of items in each feed'),
     '#default_value' => variable_get('feed_default_items', 10),
-    '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
+    '#options' => map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
     '#description' => t('Default number of items to include in each feed.')
   );
   $form['feed_item_length'] = array(
@@ -1872,7 +1874,7 @@ function system_rss_feeds_settings() {
  * @see system_regional_settings_submit()
  */
 function system_regional_settings() {
-  include_once DRUPAL_ROOT . '/core/includes/locale.inc';
+  include_once ROOT . '/core/includes/locale.inc';
   $countries = country_get_list();
 
   // Date settings:
@@ -1938,11 +1940,11 @@ function system_regional_settings() {
   $form['timezone']['configurable_timezones_wrapper']['user_default_timezone'] = array(
     '#type' => 'radios',
     '#title' => t('Time zone for new users'),
-    '#default_value' => variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT),
+    '#default_value' => variable_get('user_default_timezone', USER_TIMEZONE_DEFAULT),
     '#options' => array(
-      DRUPAL_USER_TIMEZONE_DEFAULT => t('Default time zone.'),
-      DRUPAL_USER_TIMEZONE_EMPTY   => t('Empty time zone.'),
-      DRUPAL_USER_TIMEZONE_SELECT  => t('Users may set their own time zone at registration.'),
+      USER_TIMEZONE_DEFAULT => t('Default time zone.'),
+      USER_TIMEZONE_EMPTY   => t('Empty time zone.'),
+      USER_TIMEZONE_SELECT  => t('Users may set their own time zone at registration.'),
     ),
     '#description' => t('Only applied if users may set their own time zone.')
   );
@@ -1958,12 +1960,12 @@ function system_regional_settings() {
  */
 function system_date_time_settings() {
   // Get list of all available date types.
-  drupal_static_reset('system_get_date_types');
+  drupal_static_reset('Drupal\system_get_date_types');
   $format_types = system_get_date_types();
 
   // Get list of all available date formats.
   $all_formats = array();
-  drupal_static_reset('system_get_date_formats');
+  drupal_static_reset('Drupal\system_get_date_formats');
   $date_formats = system_get_date_formats(); // Call this to rebuild the list, and to have default list.
   foreach ($date_formats as $type => $format_info) {
     $all_formats = array_merge($all_formats, $format_info);
@@ -2053,7 +2055,7 @@ function theme_system_date_time_settings($variables) {
   }
 
   $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'system-date-types')));
-  $output .= drupal_render_children($form);
+  $output .= render_children($form);
 
   return $output;
 }
@@ -2082,7 +2084,7 @@ function system_add_date_format_type_form($form, &$form_state) {
 
   // Get list of all available date formats.
   $formats = array();
-  drupal_static_reset('system_get_date_formats');
+  drupal_static_reset('Drupal\system_get_date_formats');
   $date_formats = system_get_date_formats(); // Call this to rebuild the list, and to have default list.
   foreach ($date_formats as $type => $format_info) {
     $formats = array_merge($formats, $format_info);
@@ -2145,7 +2147,7 @@ function system_add_date_format_type_form_submit($form, &$form_state) {
   system_date_format_type_save($format_type);
   variable_set('date_format_' . $machine_name, $form_state['values']['date_format']);
 
-  drupal_set_message(t('New date type added successfully.'));
+  set_message(t('New date type added successfully.'));
   $form_state['redirect'] = 'admin/config/regional/date-time';
 }
 
@@ -2154,7 +2156,7 @@ function system_add_date_format_type_form_submit($form, &$form_state) {
  */
 function system_date_time_lookup() {
   $result = format_date(REQUEST_TIME, 'custom', $_GET['format']);
-  drupal_json_output($result);
+  json_output($result);
 }
 
 /**
@@ -2195,13 +2197,13 @@ function system_clean_url_settings($form, &$form_state) {
     $available = TRUE;
   }
   else {
-    $request = drupal_http_request($GLOBALS['base_url'] . '/admin/config/search/clean-urls/check');
+    $request = http_request($GLOBALS['base_url'] . '/admin/config/search/clean-urls/check');
     // If the request returns HTTP 200, clean URLs are available.
     if (isset($request->code) && $request->code == 200) {
       $available = TRUE;
       // If the user started the clean URL test, provide explicit feedback.
       if (isset($form_state['input']['clean_url_test_execute'])) {
-        drupal_set_message(t('The clean URL test passed.'));
+        set_message(t('The clean URL test passed.'));
       }
     }
     else {
@@ -2212,12 +2214,12 @@ function system_clean_url_settings($form, &$form_state) {
         // Warn the user of a conflicting situation, unless after processing
         // a submitted form.
         if (!isset($form_state['input']['op'])) {
-          drupal_set_message(t('Clean URLs are enabled, but the clean URL test failed. Uncheck the box below to disable clean URLs.'), 'warning');
+          set_message(t('Clean URLs are enabled, but the clean URL test failed. Uncheck the box below to disable clean URLs.'), 'warning');
         }
       }
       // If the user started the clean URL test, provide explicit feedback.
       elseif (isset($form_state['input']['clean_url_test_execute'])) {
-        drupal_set_message(t('The clean URL test failed.'), 'warning');
+        set_message(t('The clean URL test failed.'), 'warning');
       }
     }
   }
@@ -2240,7 +2242,7 @@ function system_clean_url_settings($form, &$form_state) {
   }
   // Show the clean URLs test form.
   else {
-    drupal_add_js(drupal_get_path('module', 'system') . '/system.js');
+    add_js(get_path('module', 'system') . '/system.js');
 
     $form_state['redirect'] = url('admin/config/search/clean-urls');
     $form['clean_url_description'] = array(
@@ -2277,15 +2279,15 @@ function system_clean_url_settings($form, &$form_state) {
  */
 function system_status($check = FALSE) {
   // Load .install files
-  include_once DRUPAL_ROOT . '/core/includes/install.inc';
-  drupal_load_updates();
+  include_once ROOT . '/core/includes/install.inc';
+  load_updates();
 
   // Check run-time requirements and status information.
   $requirements = module_invoke_all('requirements', 'runtime');
-  usort($requirements, '_system_sort_requirements');
+  usort($requirements, 'Drupal\_system_sort_requirements');
 
   if ($check) {
-    return drupal_requirements_severity($requirements) == REQUIREMENT_ERROR;
+    return requirements_severity($requirements) == REQUIREMENT_ERROR;
   }
   // MySQL import might have set the uid of the anonymous user to autoincrement
   // value. Let's try fixing it. See http://drupal.org/node/204411
@@ -2303,14 +2305,14 @@ function system_status($check = FALSE) {
  */
 function system_run_cron() {
   // Run cron manually
-  if (drupal_cron_run()) {
-    drupal_set_message(t('Cron ran successfully.'));
+  if (cron_run()) {
+    set_message(t('Cron ran successfully.'));
   }
   else {
-    drupal_set_message(t('Cron run failed.'), 'error');
+    set_message(t('Cron run failed.'), 'error');
   }
 
-  drupal_goto('admin/reports/status');
+  redirect('admin/reports/status');
 }
 
 /**
@@ -2325,16 +2327,16 @@ function system_php() {
  * Default page callback for batches.
  */
 function system_batch_page() {
-  require_once DRUPAL_ROOT . '/core/includes/batch.inc';
+  require_once ROOT . '/core/includes/batch.inc';
   $output = _batch_page();
 
   if ($output === FALSE) {
-    drupal_access_denied();
+    access_denied();
   }
   elseif (isset($output)) {
     // Force a page without blocks or messages to
     // display a list of collected messages later.
-    drupal_set_page_content($output);
+    set_page_content($output);
     $page = element_info('page');
     $page['#show_messages'] = FALSE;
     return $page;
@@ -2662,7 +2664,7 @@ function theme_system_modules_uninstall($variables) {
   }
 
   $output  = theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No modules are available to uninstall.')));
-  $output .= drupal_render_children($form);
+  $output .= render_children($form);
 
   return $output;
 }
@@ -2705,7 +2707,7 @@ function theme_system_themes_page($variables) {
 
       // Make sure to provide feedback on compatibility.
       if (!empty($theme->incompatible_core)) {
-        $output .= '<div class="incompatible">' . t('This version is not compatible with Drupal !core_version and should be replaced.', array('!core_version' => DRUPAL_CORE_COMPATIBILITY)) . '</div>';
+        $output .= '<div class="incompatible">' . t('This version is not compatible with Drupal !core_version and should be replaced.', array('!core_version' => CORE_COMPATIBILITY)) . '</div>';
       }
       elseif (!empty($theme->incompatible_php)) {
         if (substr_count($theme->info['php'], '.') < 2) {
@@ -2753,7 +2755,7 @@ function system_date_delete_format_form_submit($form, &$form_state) {
   if ($form_state['values']['confirm']) {
     $format = system_get_date_format($form_state['values']['dfid']);
     system_date_format_delete($form_state['values']['dfid']);
-    drupal_set_message(t('Removed date format %format.', array('%format' => format_date(REQUEST_TIME, 'custom', $format->format))));
+    set_message(t('Removed date format %format.', array('%format' => format_date(REQUEST_TIME, 'custom', $format->format))));
     $form_state['redirect'] = 'admin/config/regional/date-time/formats';
   }
 }
@@ -2786,7 +2788,7 @@ function system_delete_date_format_type_form_submit($form, &$form_state) {
   if ($form_state['values']['confirm']) {
     $type_info = system_get_date_types($form_state['values']['format_type']);
     system_date_format_type_delete($form_state['values']['format_type']);
-    drupal_set_message(t('Removed date type %type.', array('%type' => $type_info['title'])));
+    set_message(t('Removed date type %type.', array('%type' => $type_info['title'])));
     $form_state['redirect'] = 'admin/config/regional/date-time';
   }
 }
@@ -2799,7 +2801,7 @@ function system_date_time_formats() {
   $header = array(t('Format'), array('data' => t('Operations'), 'colspan' => '2'));
   $rows = array();
 
-  drupal_static_reset('system_get_date_formats');
+  drupal_static_reset('Drupal\system_get_date_formats');
   $formats = system_get_date_formats('custom');
   if (!empty($formats)) {
     foreach ($formats as $format) {
@@ -2855,7 +2857,7 @@ function system_configure_date_formats_form($form, &$form_state, $dfid = 0) {
     '#default_value' => ($dfid ? $format->format : ''),
     '#field_suffix' => ' <small id="edit-date-format-suffix">' . $now . '</small>',
     '#attached' => array(
-      'js' => array(drupal_get_path('module', 'system') . '/system.js', $js_settings),
+      'js' => array(get_path('module', 'system') . '/system.js', $js_settings),
     ),
     '#required' => TRUE,
   );
@@ -2893,12 +2895,12 @@ function system_add_date_formats_form_submit($form, &$form_state) {
   $format['locked'] = 0;
   if (!empty($form_state['values']['dfid'])) {
     system_date_format_save($format, $form_state['values']['dfid']);
-    drupal_set_message(t('Custom date format updated.'));
+    set_message(t('Custom date format updated.'));
   }
   else {
     $format['is_new'] = 1;
     system_date_format_save($format);
-    drupal_set_message(t('Custom date format added.'));
+    set_message(t('Custom date format added.'));
   }
 
   $form_state['redirect'] = 'admin/config/regional/date-time/formats';
@@ -2956,7 +2958,7 @@ function system_actions_manage() {
   }
 
   if ($actions_map) {
-    $build['system_actions_manage_form'] = drupal_get_form('system_actions_manage_form', $options);
+    $build['system_actions_manage_form'] = get_form('system_actions_manage_form', $options);
   }
 
   return $build;
@@ -3027,7 +3029,7 @@ function system_actions_manage_form_submit($form, &$form_state) {
  */
 function system_actions_configure($form, &$form_state, $action = NULL) {
   if ($action === NULL) {
-    drupal_goto('admin/config/system/actions');
+    redirect('admin/config/system/actions');
   }
 
   $actions_map = actions_actions_map(actions_list());
@@ -3041,7 +3043,7 @@ function system_actions_configure($form, &$form_state, $action = NULL) {
     $edit['actions_label'] = $data->label;
     $edit['actions_type'] = $data->type;
     $function = $data->callback;
-    $action = drupal_hash_base64($data->callback);
+    $action = hash_base64($data->callback);
     $params = unserialize($data->parameters);
     if ($params) {
       foreach ($params as $name => $val) {
@@ -3064,7 +3066,7 @@ function system_actions_configure($form, &$form_state, $action = NULL) {
     '#description' => t('A unique label for this advanced action. This label will be displayed in the interface of modules that integrate with actions.'),
     '#weight' => -10
   );
-  $action_form = $function . '_form';
+  $action_form = 'Drupal\\' . $function . '_form';
   $form = array_merge($form, $action_form($edit));
   $form['actions_type'] = array(
     '#type' => 'value',
@@ -3099,7 +3101,7 @@ function system_actions_configure($form, &$form_state, $action = NULL) {
  * Validate system_actions_configure() form submissions.
  */
 function system_actions_configure_validate($form, &$form_state) {
-  $function = actions_function_lookup($form_state['values']['actions_action']) . '_validate';
+  $function = 'Drupal\\' . actions_function_lookup($form_state['values']['actions_action']) . '_validate';
   // Hand off validation to the action.
   if (function_exists($function)) {
     $function($form, $form_state);
@@ -3111,14 +3113,14 @@ function system_actions_configure_validate($form, &$form_state) {
  */
 function system_actions_configure_submit($form, &$form_state) {
   $function = actions_function_lookup($form_state['values']['actions_action']);
-  $submit_function = $function . '_submit';
+  $submit_function = 'Drupal\\' . $function . '_submit';
 
   // Action will return keyed array of values to store.
   $params = $submit_function($form, $form_state);
   $aid = isset($form_state['values']['actions_aid']) ? $form_state['values']['actions_aid'] : NULL;
 
   actions_save($function, $form_state['values']['actions_type'], $params, $form_state['values']['actions_label'], $aid);
-  drupal_set_message(t('The action has been successfully saved.'));
+  set_message(t('The action has been successfully saved.'));
 
   $form_state['redirect'] = 'admin/config/system/actions/manage';
 }
@@ -3153,7 +3155,7 @@ function system_actions_delete_form_submit($form, &$form_state) {
   $action = actions_load($aid);
   actions_delete($aid);
   watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $aid, '%action' => $action->label));
-  drupal_set_message(t('Action %action was deleted', array('%action' => $action->label)));
+  set_message(t('Action %action was deleted', array('%action' => $action->label)));
   $form_state['redirect'] = 'admin/config/system/actions/manage';
 }
 
@@ -3165,7 +3167,7 @@ function system_actions_delete_form_submit($form, &$form_state) {
  */
 function system_action_delete_orphans_post($orphaned) {
   foreach ($orphaned as $callback) {
-    drupal_set_message(t("Deleted orphaned action (%action).", array('%action' => $callback)));
+    set_message(t("Deleted orphaned action (%action).", array('%action' => $callback)));
   }
 }
 
@@ -3174,5 +3176,5 @@ function system_action_delete_orphans_post($orphaned) {
  */
 function system_actions_remove_orphans() {
   actions_synchronize(TRUE);
-  drupal_goto('admin/config/system/actions/manage');
+  redirect('admin/config/system/actions/manage');
 }
diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php
index e8026e6..0a785e9 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, PDO, PDOException;
 
 /**
  * @file
@@ -72,12 +74,12 @@ function hook_hook_info_alter(&$hooks) {
  *
  * @return
  *   An associative array. For each item, the key is the path in question, in
- *   a format acceptable to drupal_match_path(). The value for each item should
+ *   a format acceptable to match_path(). The value for each item should
  *   be TRUE (for paths considered administrative) or FALSE (for non-
  *   administrative paths).
  *
  * @see hook_menu()
- * @see drupal_match_path()
+ * @see match_path()
  * @see hook_admin_paths_alter()
  */
 function hook_admin_paths() {
@@ -138,7 +140,7 @@ function hook_cron() {
     ':time' => REQUEST_TIME,
     ':never' => AGGREGATOR_CLEAR_NEVER,
   ));
-  $queue = DrupalQueue::get('aggregator_feeds');
+  $queue = Queue::get('aggregator_feeds');
   foreach ($result as $feed) {
     $queue->createItem($feed);
   }
@@ -158,7 +160,7 @@ function hook_cron() {
  *   An associative array where the key is the queue name and the value is
  *   again an associative array. Possible keys are:
  *   - 'worker callback': The name of the function to call. It will be called
- *     with one argument, the item created via DrupalQueue::createItem() in
+ *     with one argument, the item created via Queue::createItem() in
  *     hook_cron().
  *   - 'time': (optional) How much time Drupal should spend on calling this
  *     worker in seconds. Defaults to 15.
@@ -177,14 +179,14 @@ function hook_cron_queue_info() {
 /**
  * Alter cron queue information before cron runs.
  *
- * Called by drupal_cron_run() to allow modules to alter cron queue settings
+ * Called by cron_run() to allow modules to alter cron queue settings
  * before any jobs are processesed.
  *
  * @param array $queues
  *   An array of cron queue information.
  *
  * @see hook_cron_queue_info()
- * @see drupal_cron_run()
+ * @see cron_run()
  */
 function hook_cron_queue_info_alter(&$queues) {
   // This site has many feeds so let's spend 90 seconds on each cron run
@@ -269,7 +271,7 @@ function hook_element_info_alter(&$type) {
  * It is not loaded because Drupal is still in bootstrap mode.
  *
  * @param $destination
- *   If this hook is invoked as part of a drupal_goto() call, then this argument
+ *   If this hook is invoked as part of a redirect() call, then this argument
  *   will be a fully-qualified URL that is the destination of the redirect.
  */
 function hook_exit($destination = NULL) {
@@ -286,13 +288,13 @@ function hook_exit($destination = NULL) {
  * @param $javascript
  *   An array of all JavaScript being presented on the page.
  *
- * @see drupal_add_js()
- * @see drupal_get_js()
- * @see drupal_js_defaults()
+ * @see add_js()
+ * @see get_js()
+ * @see js_defaults()
  */
 function hook_js_alter(&$javascript) {
   // Swap out jQuery to use an updated version of the library.
-  $javascript['core/misc/jquery.js']['data'] = drupal_get_path('module', 'jquery_update') . '/jquery.js';
+  $javascript['core/misc/jquery.js']['data'] = get_path('module', 'jquery_update') . '/jquery.js';
 }
 
 /**
@@ -309,11 +311,11 @@ function hook_js_alter(&$javascript) {
  *   version_compare() to compare different versions.
  * - 'js': An array of JavaScript elements; each element's key is used as $data
  *   argument, each element's value is used as $options array for
- *   drupal_add_js(). To add library-specific (not module-specific) JavaScript
+ *   add_js(). To add library-specific (not module-specific) JavaScript
  *   settings, the key may be skipped, the value must specify
  *   'type' => 'setting', and the actual settings must be contained in a 'data'
  *   element of the value.
- * - 'css': Like 'js', an array of CSS elements passed to drupal_add_css().
+ * - 'css': Like 'js', an array of CSS elements passed to add_css().
  * - 'dependencies': An array of libraries that are required for a library. Each
  *   element is an array listing the module and name of another library. Note
  *   that all dependencies for each dependent library will also be added when
@@ -327,8 +329,8 @@ function hook_js_alter(&$javascript) {
  *   An array defining libraries associated with a module.
  *
  * @see system_library_info()
- * @see drupal_add_library()
- * @see drupal_get_library()
+ * @see add_library()
+ * @see get_library()
  */
 function hook_library_info() {
   // Library One.
@@ -337,10 +339,10 @@ function hook_library_info() {
     'website' => 'http://example.com/library-1',
     'version' => '1.2',
     'js' => array(
-      drupal_get_path('module', 'my_module') . '/library-1.js' => array(),
+      get_path('module', 'my_module') . '/library-1.js' => array(),
     ),
     'css' => array(
-      drupal_get_path('module', 'my_module') . '/library-2.css' => array(
+      get_path('module', 'my_module') . '/library-2.css' => array(
         'type' => 'file',
         'media' => 'screen',
       ),
@@ -394,7 +396,7 @@ function hook_library_info_alter(&$libraries, $module) {
       // Update the existing Farbtastic to version 2.0.
       $libraries['farbtastic']['version'] = '2.0';
       $libraries['farbtastic']['js'] = array(
-        drupal_get_path('module', 'farbtastic_update') . '/farbtastic-2.0.js' => array(),
+        get_path('module', 'farbtastic_update') . '/farbtastic-2.0.js' => array(),
       );
     }
   }
@@ -406,12 +408,12 @@ function hook_library_info_alter(&$libraries, $module) {
  * @param $css
  *   An array of all CSS items (files and inline CSS) being requested on the page.
  *
- * @see drupal_add_css()
- * @see drupal_get_css()
+ * @see add_css()
+ * @see get_css()
  */
 function hook_css_alter(&$css) {
   // Remove defaults.css file.
-  unset($css[drupal_get_path('module', 'system') . '/defaults.css']);
+  unset($css[get_path('module', 'system') . '/defaults.css']);
 }
 
 /**
@@ -447,7 +449,7 @@ function hook_ajax_render_alter($commands) {
  *   Nested array of renderable elements that make up the page.
  *
  * @see hook_page_alter()
- * @see drupal_render_page()
+ * @see render_page()
  */
 function hook_page_build(&$page) {
   if (menu_get_object('node', 1)) {
@@ -561,7 +563,7 @@ function hook_menu_get_item_alter(&$router_item, $path, $original_map) {
  * mymodule_abc_view() will be called with 'def', 'foo', 'bar' and 'baz' as
  * arguments, in that order.
  *
- * Special care should be taken for the page callback drupal_get_form(), because
+ * Special care should be taken for the page callback get_form(), because
  * your specific form callback function will always receive $form and
  * &$form_state as the first function arguments:
  * @code
@@ -683,10 +685,10 @@ function hook_menu_get_item_alter(&$router_item, $path, $original_map) {
  *     function, with path component substitution as described above.
  *   - "delivery callback": The function to call to package the result of the
  *     page callback function and send it to the browser. Defaults to
- *     drupal_deliver_html_page() unless a value is inherited from a parent menu
+ *     deliver_html_page() unless a value is inherited from a parent menu
  *     item. Note that this function is called even if the access checks fail,
  *     so any custom delivery callback function should take that into account.
- *     See drupal_deliver_html_page() for an example.
+ *     See deliver_html_page() for an example.
  *   - "access callback": A function returning TRUE if the user has access
  *     rights to this menu item, and FALSE if not. It can also be a boolean
  *     constant instead of a function, and you can also use numeric values
@@ -876,7 +878,7 @@ function hook_menu_link_alter(&$item) {
  */
 function hook_translated_menu_link_alter(&$item, $map) {
   if ($item['href'] == 'devel/cache/clear') {
-    $item['localized_options']['query'] = drupal_get_destination();
+    $item['localized_options']['query'] = get_destination();
   }
 }
 
@@ -899,7 +901,7 @@ function hook_menu_link_insert($link) {
   $record['mlid'] = $link['mlid'];
   $record['menu_name'] = $link['menu_name'];
   $record['status'] = 0;
-  drupal_write_record('menu_example', $record);
+  write_record('menu_example', $record);
 }
 
 /**
@@ -1018,7 +1020,7 @@ function hook_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  *
  * This hook is invoked by menu_get_active_breadcrumb() and allows alteration
  * of the breadcrumb links for the current page, which may be preferred instead
- * of setting a custom breadcrumb via drupal_set_breadcrumb().
+ * of setting a custom breadcrumb via set_breadcrumb().
  *
  * Implementations should take into account that menu_get_active_breadcrumb()
  * subsequently performs the following adjustments to the active trail *after*
@@ -1042,7 +1044,7 @@ function hook_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  * @param $item
  *   The menu router item of the current page.
  *
- * @see drupal_set_breadcrumb()
+ * @see set_breadcrumb()
  * @see menu_get_active_breadcrumb()
  * @see menu_get_active_trail()
  * @see menu_set_active_trail()
@@ -1052,7 +1054,7 @@ function hook_menu_breadcrumb_alter(&$active_trail, $item) {
   // the active trail. This means that menu_get_active_breadcrumb() will remove
   // the last link (for the current page), but since it is added once more here,
   // it will appear.
-  if (!drupal_is_front_page()) {
+  if (!is_front_page()) {
     $end = end($active_trail);
     if ($item['href'] == $end['href']) {
       $active_trail[] = $end;
@@ -1153,7 +1155,7 @@ function hook_menu_contextual_links_alter(&$links, $router_item, $root_path) {
  *   Nested array of renderable elements that make up the page.
  *
  * @see hook_page_build()
- * @see drupal_render_page()
+ * @see render_page()
  */
 function hook_page_alter(&$page) {
   // Add help text to the user login block.
@@ -1189,7 +1191,7 @@ function hook_page_alter(&$page) {
  *   Nested array of form elements that comprise the form.
  * @param $form_state
  *   A keyed array containing the current state of the form. The arguments
- *   that drupal_get_form() was originally called with are available in the
+ *   that get_form() was originally called with are available in the
  *   array $form_state['build_info']['args'].
  * @param $form_id
  *   String representing the name of the form itself. Typically this is the
@@ -1224,7 +1226,7 @@ function hook_form_alter(&$form, &$form_state, $form_id) {
  *   Nested array of form elements that comprise the form.
  * @param $form_state
  *   A keyed array containing the current state of the form. The arguments
- *   that drupal_get_form() was originally called with are available in the
+ *   that get_form() was originally called with are available in the
  *   array $form_state['build_info']['args'].
  * @param $form_id
  *   String representing the name of the form itself. Typically this is the
@@ -1232,7 +1234,7 @@ function hook_form_alter(&$form, &$form_state, $form_id) {
  *
  * @see hook_form_alter()
  * @see hook_form_BASE_FORM_ID_alter()
- * @see drupal_prepare_form()
+ * @see prepare_form()
  */
 function hook_form_FORM_ID_alter(&$form, &$form_state, $form_id) {
   // Modification for the form with the given form ID goes here. For example, if
@@ -1250,7 +1252,7 @@ function hook_form_FORM_ID_alter(&$form, &$form_state, $form_id) {
 /**
  * Provide a form-specific alteration for shared ('base') forms.
  *
- * By default, when drupal_get_form() is called, Drupal looks for a function
+ * By default, when get_form() is called, Drupal looks for a function
  * with the same name as the form ID, and uses that function to build the form.
  * In contrast, base forms allow multiple form IDs to be mapped to a single base
  * (also called 'factory') form function.
@@ -1280,7 +1282,7 @@ function hook_form_FORM_ID_alter(&$form, &$form_state, $form_id) {
  *
  * @see hook_form_alter()
  * @see hook_form_FORM_ID_alter()
- * @see drupal_prepare_form()
+ * @see prepare_form()
  * @see hook_forms()
  */
 function hook_form_BASE_FORM_ID_alter(&$form, &$form_state, $form_id) {
@@ -1299,7 +1301,7 @@ function hook_form_BASE_FORM_ID_alter(&$form, &$form_state, $form_id) {
 /**
  * Map form_ids to form builder functions.
  *
- * By default, when drupal_get_form() is called, the system will look for a
+ * By default, when get_form() is called, the system will look for a
  * function with the same name as the form ID, and use that function to build
  * the form. If no such function is found, Drupal calls this hook. Modules
  * implementing this hook can then provide their own instructions for mapping
@@ -1329,8 +1331,8 @@ function hook_form_BASE_FORM_ID_alter(&$form, &$form_state, $form_id) {
  * @param $form_id
  *   The unique string identifying the desired form.
  * @param $args
- *   An array containing the original arguments provided to drupal_get_form()
- *   or drupal_form_submit(). These are always passed to the form builder and
+ *   An array containing the original arguments provided to get_form()
+ *   or form_submit(). These are always passed to the form builder and
  *   do not have to be specified manually in 'callback arguments'.
  *
  * @return
@@ -1389,8 +1391,8 @@ function hook_forms($form_id, $args) {
  */
 function hook_boot() {
   // We need user_access() in the shutdown function. Make sure it gets loaded.
-  drupal_load('module', 'user');
-  drupal_register_shutdown_function('devel_shutdown');
+  load('module', 'user');
+  drupal_register_shutdown_function('Drupal\devel_shutdown');
 }
 
 /**
@@ -1410,8 +1412,8 @@ function hook_boot() {
 function hook_init() {
   // Since this file should only be loaded on the front page, it cannot be
   // declared in the info file.
-  if (drupal_is_front_page()) {
-    drupal_add_css(drupal_get_path('module', 'foo') . '/foo.css');
+  if (is_front_page()) {
+    add_css(get_path('module', 'foo') . '/foo.css');
   }
 }
 
@@ -1454,23 +1456,23 @@ function hook_image_toolkits() {
 }
 
 /**
- * Alter an email message created with the drupal_mail() function.
+ * Alter an email message created with the mail() function.
  *
  * hook_mail_alter() allows modification of email messages created and sent
- * with drupal_mail(). Usage examples include adding and/or changing message
+ * with mail(). Usage examples include adding and/or changing message
  * text, message fields, and message headers.
  *
- * Email messages sent using functions other than drupal_mail() will not
+ * Email messages sent using functions other than mail() will not
  * invoke hook_mail_alter(). For example, a contributed module directly
- * calling the drupal_mail_system()->mail() or PHP mail() function
- * will not invoke this hook. All core modules use drupal_mail() for
+ * calling the mail_system()->mail() or PHP mail() function
+ * will not invoke this hook. All core modules use mail() for
  * messaging, it is best practice but not mandatory in contributed modules.
  *
  * @param $message
  *   An array containing the message data. Keys in this array include:
  *  - 'id':
- *     The drupal_mail() id of the message. Look at module source code or
- *     drupal_mail() for possible id values.
+ *     The mail() id of the message. Look at module source code or
+ *     mail() for possible id values.
  *  - 'to':
  *     The address or addresses the message will be sent to. The
  *     formatting of this string must comply with RFC 2822.
@@ -1488,7 +1490,7 @@ function hook_image_toolkits() {
  *     Associative array containing mail headers, such as From, Sender,
  *     MIME-Version, Content-Type, etc.
  *  - 'params':
- *     An array of optional parameters supplied by the caller of drupal_mail()
+ *     An array of optional parameters supplied by the caller of mail()
  *     that is used to build the message before hook_mail_alter() is invoked.
  *  - 'language':
  *     The language object used to build the message before hook_mail_alter()
@@ -1496,7 +1498,7 @@ function hook_image_toolkits() {
  *  - 'send':
  *     Set to FALSE to abort sending this email message.
  *
- * @see drupal_mail()
+ * @see mail()
  */
 function hook_mail_alter(&$message) {
   if ($message['id'] == 'modulename_messagekey') {
@@ -1517,8 +1519,8 @@ function hook_mail_alter(&$message) {
  * hook in order to reorder the implementing modules, which are otherwise
  * ordered by the module's system weight.
  *
- * Note that hooks invoked using drupal_alter() can have multiple variations
- * (such as hook_form_alter() and hook_form_FORM_ID_alter()). drupal_alter()
+ * Note that hooks invoked using alter() can have multiple variations
+ * (such as hook_form_alter() and hook_form_FORM_ID_alter()). alter()
  * will call all such variants defined by a single module in turn. For the
  * purposes of hook_module_implements_alter(), these variants are treated as
  * a single hook. Thus, to ensure that your implementation of
@@ -1560,7 +1562,7 @@ function hook_module_implements_alter(&$implementations, $hook) {
  *   is the corresponding path to the theme's .info file.
  */
 function hook_system_theme_info() {
-  $themes['mymodule_test_theme'] = drupal_get_path('module', 'mymodule') . '/mymodule_test_theme/mymodule_test_theme.info';
+  $themes['mymodule_test_theme'] = get_path('module', 'mymodule') . '/mymodule_test_theme/mymodule_test_theme.info';
   return $themes;
 }
 
@@ -1570,7 +1572,7 @@ function hook_system_theme_info() {
  * This hook is invoked in _system_rebuild_module_data() and in
  * _system_rebuild_theme_data(). A module may implement this hook in order to
  * add to or alter the data generated by reading the .info file with
- * drupal_parse_info_file().
+ * parse_info_file().
  *
  * @param $info
  *   The .info file contents, passed by reference so that it can be altered.
@@ -1987,37 +1989,37 @@ function hook_watchdog(array $log_entry) {
     '@message'       => strip_tags($log_entry['message']),
   ));
 
-  drupal_mail('emaillog', 'entry', $to, $language, $params);
+  mail('emaillog', 'entry', $to, $language, $params);
 }
 
 /**
- * Prepare a message based on parameters; called from drupal_mail().
+ * Prepare a message based on parameters; called from mail().
  *
  * Note that hook_mail(), unlike hook_mail_alter(), is only called on the
- * $module argument to drupal_mail(), not all modules.
+ * $module argument to mail(), not all modules.
  *
  * @param $key
  *   An identifier of the mail.
  * @param $message
  *   An array to be filled in. Elements in this array include:
  *   - id: An ID to identify the mail sent. Look at module source code
- *     or drupal_mail() for possible id values.
+ *     or mail() for possible id values.
  *   - to: The address or addresses the message will be sent to. The
  *     formatting of this string must comply with RFC 2822.
  *   - subject: Subject of the e-mail to be sent. This must not contain any
- *     newline characters, or the mail may not be sent properly. drupal_mail()
+ *     newline characters, or the mail may not be sent properly. mail()
  *     sets this to an empty string when the hook is invoked.
  *   - body: An array of lines containing the message to be sent. Drupal will
- *     format the correct line endings for you. drupal_mail() sets this to an
+ *     format the correct line endings for you. mail() sets this to an
  *     empty array when the hook is invoked.
  *   - from: The address the message will be marked as being from, which is
- *     set by drupal_mail() to either a custom address or the site-wide
+ *     set by mail() to either a custom address or the site-wide
  *     default email address when the hook is invoked.
  *   - headers: Associative array containing mail headers, such as From,
- *     Sender, MIME-Version, Content-Type, etc. drupal_mail() pre-fills
+ *     Sender, MIME-Version, Content-Type, etc. mail() pre-fills
  *     several headers in this array.
  * @param $params
- *   An array of parameters supplied by the caller of drupal_mail().
+ *   An array of parameters supplied by the caller of mail().
  */
 function hook_mail($key, &$message, $params) {
   $account = $params['account'];
@@ -2054,7 +2056,7 @@ function hook_mail($key, &$message, $params) {
   $subject = strtr($context['subject'], $variables);
   $body = strtr($context['message'], $variables);
   $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
-  $message['body'][] = drupal_html_to_text($body);
+  $message['body'][] = html_to_text($body);
 }
 
 /**
@@ -2062,12 +2064,12 @@ function hook_mail($key, &$message, $params) {
  *
  * This hook allows your module to add cache bins to the list of cache bins
  * that will be cleared by the Clear button on the Performance page or
- * whenever drupal_flush_all_caches is invoked.
+ * whenever flush_all_caches is invoked.
  *
  * @return
  *   An array of cache bins.
  *
- * @see drupal_flush_all_caches()
+ * @see flush_all_caches()
  */
 function hook_flush_caches() {
   return array('example');
@@ -2137,7 +2139,7 @@ function hook_modules_installed($modules) {
  */
 function hook_modules_enabled($modules) {
   if (in_array('lousy_module', $modules)) {
-    drupal_set_message(t('mymodule is not compatible with lousy_module'), 'error');
+    set_message(t('mymodule is not compatible with lousy_module'), 'error');
     mymodule_disable_functionality();
   }
 }
@@ -2220,13 +2222,13 @@ function hook_stream_wrappers() {
   return array(
     'public' => array(
       'name' => t('Public files'),
-      'class' => 'DrupalPublicStreamWrapper',
+      'class' => 'PublicStreamWrapper',
       'description' => t('Public local files served by the webserver.'),
       'type' => STREAM_WRAPPERS_LOCAL_NORMAL,
     ),
     'private' => array(
       'name' => t('Private files'),
-      'class' => 'DrupalPrivateStreamWrapper',
+      'class' => 'PrivateStreamWrapper',
       'description' => t('Private local files served by Drupal.'),
       'type' => STREAM_WRAPPERS_LOCAL_NORMAL,
     ),
@@ -2596,8 +2598,8 @@ function hook_requirements($phase) {
     'title' => $t('PHP'),
     'value' => ($phase == 'runtime') ? l(phpversion(), 'admin/reports/status/php') : phpversion(),
   );
-  if (version_compare(phpversion(), DRUPAL_MINIMUM_PHP) < 0) {
-    $requirements['php']['description'] = $t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => DRUPAL_MINIMUM_PHP));
+  if (version_compare(phpversion(), MINIMUM_PHP) < 0) {
+    $requirements['php']['description'] = $t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => MINIMUM_PHP));
     $requirements['php']['severity'] = REQUIREMENT_ERROR;
   }
 
@@ -2633,7 +2635,7 @@ function hook_requirements($phase) {
  *
  * This hook is called at both install and uninstall time, and in the latter
  * case, it cannot rely on the .module file being loaded or hooks being known.
- * If the .module file is needed, it may be loaded with drupal_load().
+ * If the .module file is needed, it may be loaded with load().
  *
  * The tables declared by this hook will be automatically created when
  * the module is first enabled, and removed when the module is uninstalled.
@@ -2898,8 +2900,8 @@ function hook_install() {
  * @param $sandbox
  *   Stores information for multipass updates. See above for more information.
  *
- * @throws DrupalUpdateException, PDOException
- *   In case of error, update hooks should throw an instance of DrupalUpdateException
+ * @throws UpdateException, PDOException
+ *   In case of error, update hooks should throw an instance of UpdateException
  *   with a meaningful message for the user. If a database query fails for whatever
  *   reason, it will throw a PDOException.
  *
@@ -2952,7 +2954,7 @@ function hook_update_N(&$sandbox) {
   return t('The update did what it was supposed to do.');
 
   // In case of an error, simply throw an exception with an error message.
-  throw new DrupalUpdateException('Something went wrong; here is what you should do.');
+  throw new UpdateException('Something went wrong; here is what you should do.');
 }
 
 /**
@@ -3039,7 +3041,7 @@ function hook_update_last_removed() {
  *
  * When hook_uninstall() is called, your module will already be disabled, so
  * its .module file will not be automatically included. If you need to call API
- * functions from your .module file in this hook, use drupal_load() to make
+ * functions from your .module file in this hook, use load() to make
  * them available. (Keep this usage to a minimum, though, especially when
  * calling API functions that invoke hooks, or API functions from modules
  * listed as dependencies, since these may not be available or work as expected
@@ -3155,7 +3157,7 @@ function hook_registry_files_alter(&$files, $modules) {
  * installer to pause and display a page to the user by returning any themed
  * output that should be displayed on that page (but see below for tasks that
  * use the form API or batch API; the return values of these task functions are
- * handled differently). You should also use drupal_set_title() within the task
+ * handled differently). You should also use set_title() within the task
  * callback function to set a custom page title. For some tasks, however, you
  * may want to simply do some processing and pass control to the next task
  * without ending the page request; to indicate this, simply do not send back
@@ -3302,27 +3304,27 @@ function hook_install_tasks() {
 }
 
 /**
- * Change the page the user is sent to by drupal_goto().
+ * Change the page the user is sent to by redirect().
  *
  * @param $path
  *   A Drupal path or a full URL.
  * @param $options
  *   An associative array of additional URL options to pass to url().
  * @param $http_response_code
- *   The HTTP status code to use for the redirection. See drupal_goto() for more
+ *   The HTTP status code to use for the redirection. See redirect() for more
  *   information.
  */
-function hook_drupal_goto_alter(&$path, &$options, &$http_response_code) {
+function hook_redirect_alter(&$path, &$options, &$http_response_code) {
   // A good addition to misery module.
   $http_response_code = 500;
 }
 
 /**
- * Alter XHTML HEAD tags before they are rendered by drupal_get_html_head().
+ * Alter XHTML HEAD tags before they are rendered by get_html_head().
  *
  * Elements available to be altered are only those added using
- * drupal_add_html_head_link() or drupal_add_html_head(). CSS and JS files
- * are handled using drupal_add_css() and drupal_add_js(), so the head links
+ * add_html_head_link() or add_html_head(). CSS and JS files
+ * are handled using add_css() and add_js(), so the head links
  * for those files will not appear in the $head_elements array.
  *
  * @param $head_elements
@@ -3648,7 +3650,7 @@ function hook_date_formats_alter(&$formats) {
 /**
  * Alters the delivery callback used to send the result of the page callback to the browser.
  *
- * Called by drupal_deliver_page() to allow modules to alter how the
+ * Called by deliver_page() to allow modules to alter how the
  * page is delivered to the browser.
  *
  * This hook is intended for altering the delivery callback based on
@@ -3679,13 +3681,13 @@ function hook_date_formats_alter(&$formats) {
  * @param $callback
  *   The name of a function.
  *
- * @see drupal_deliver_page()
+ * @see deliver_page()
  */
 function hook_page_delivery_callback_alter(&$callback) {
   // jQuery sets a HTTP_X_REQUESTED_WITH header of 'XMLHttpRequest'.
   // If a page would normally be delivered as an html page, and it is called
   // from jQuery, deliver it instead as an Ajax response.
-  if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' && $callback == 'drupal_deliver_html_page') {
+  if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' && $callback == 'deliver_html_page') {
     $callback = 'ajax_deliver';
   }
 }
@@ -3724,7 +3726,7 @@ function hook_system_themes_page_alter(&$theme_groups) {
  * @param $path_language
  *   The language of the path.
  *
- * @see drupal_get_normal_path()
+ * @see get_normal_path()
  */
 function hook_url_inbound_alter(&$path, $original_path, $path_language) {
   // Create the path user/me/edit, which allows a user to edit their account.
@@ -4056,7 +4058,7 @@ function hook_batch_alter(&$batch) {
  *     doesn't matter, but if you need to override an existing Updater, make
  *     sure your Updater has a lighter weight so that it comes first.
  *
- * @see drupal_get_updaters()
+ * @see get_updaters()
  * @see hook_updater_info_alter()
  */
 function hook_updater_info() {
@@ -4085,7 +4087,7 @@ function hook_updater_info() {
  *   Associative array of updaters as defined through hook_updater_info().
  *   Alter this array directly.
  *
- * @see drupal_get_updaters()
+ * @see get_updaters()
  * @see hook_updater_info()
  */
 function hook_updater_info_alter(&$updaters) {
@@ -4120,7 +4122,7 @@ function hook_countries_alter(&$countries) {
  *   Supported values are MENU_SITE_OFFLINE, MENU_ACCESS_DENIED,
  *   MENU_NOT_FOUND and MENU_SITE_ONLINE. Any other value than
  *   MENU_SITE_ONLINE will skip the default menu handling system and be passed
- *   for delivery to drupal_deliver_page() with a NULL
+ *   for delivery to deliver_page() with a NULL
  *   $default_delivery_callback.
  * @param $path
  *   Contains the system path that is going to be loaded. This is read only,
@@ -4166,7 +4168,7 @@ function hook_menu_site_status_alter(&$menu_site_status, $path) {
  * @see FileTransfer
  * @see authorize.php
  * @see hook_filetransfer_info_alter()
- * @see drupal_get_filetransfer_info()
+ * @see get_filetransfer_info()
  */
 function hook_filetransfer_info() {
   $info['sftp'] = array(
diff --git a/core/modules/system/system.archiver.inc b/core/modules/system/system.archiver.inc
index c37f07d..cf84b60 100644
--- a/core/modules/system/system.archiver.inc
+++ b/core/modules/system/system.archiver.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index 7a275e8..f24cd61 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use PDO;
 
 /**
  * @file
@@ -30,7 +32,7 @@ function system_requirements($phase) {
 
     // Display the currently active install profile, if the site
     // is not running the default install profile.
-    $profile = drupal_get_profile();
+    $profile = get_profile();
     if ($profile != 'standard') {
       $info = system_get_info('module', $profile);
       $requirements['install_profile'] = array(
@@ -70,8 +72,8 @@ function system_requirements($phase) {
     );
   }
 
-  if (version_compare($phpversion, DRUPAL_MINIMUM_PHP) < 0) {
-    $requirements['php']['description'] = $t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => DRUPAL_MINIMUM_PHP));
+  if (version_compare($phpversion, MINIMUM_PHP) < 0) {
+    $requirements['php']['description'] = $t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => MINIMUM_PHP));
     $requirements['php']['severity'] = REQUIREMENT_ERROR;
     // If PHP is old, it's not safe to continue with the requirements check.
     return $requirements;
@@ -152,7 +154,7 @@ function system_requirements($phase) {
     }
     else {
       // Make sure at least one supported database driver exists.
-      $drivers = drupal_detect_database_types();
+      $drivers = detect_database_types();
       if (empty($drivers)) {
         $database_ok = FALSE;
         $pdo_message = $t('Your web server does not appear to support any common PDO database extensions. Check with your hosting provider to see if they support PDO (PHP Data Objects) and offer any databases that <a href="@drupal-databases">Drupal supports</a>.', array(
@@ -180,7 +182,7 @@ function system_requirements($phase) {
   }
   else {
     // Database information.
-    $class = 'DatabaseTasks_' . Database::getConnection()->driver();
+    $class = 'Drupal\DatabaseTasks_' . Database::getConnection()->driver();
     $tasks = new $class();
     $requirements['database_system'] = array(
       'title' => $t('Database system'),
@@ -199,16 +201,16 @@ function system_requirements($phase) {
     'value' => $memory_limit == -1 ? t('-1 (Unlimited)') : $memory_limit,
   );
 
-  if ($memory_limit && $memory_limit != -1 && parse_size($memory_limit) < parse_size(DRUPAL_MINIMUM_PHP_MEMORY_LIMIT)) {
+  if ($memory_limit && $memory_limit != -1 && parse_size($memory_limit) < parse_size(MINIMUM_PHP_MEMORY_LIMIT)) {
     $description = '';
     if ($phase == 'install') {
-      $description = $t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the installation process.', array('%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT));
+      $description = $t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the installation process.', array('%memory_minimum_limit' => MINIMUM_PHP_MEMORY_LIMIT));
     }
     elseif ($phase == 'update') {
-      $description = $t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the update process.', array('%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT));
+      $description = $t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the update process.', array('%memory_minimum_limit' => MINIMUM_PHP_MEMORY_LIMIT));
     }
     elseif ($phase == 'runtime') {
-      $description = $t('Depending on your configuration, Drupal can run with a %memory_limit PHP memory limit. However, a %memory_minimum_limit PHP memory limit or above is recommended, especially if your site uses additional custom or contributed modules.', array('%memory_limit' => $memory_limit, '%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT));
+      $description = $t('Depending on your configuration, Drupal can run with a %memory_limit PHP memory limit. However, a %memory_minimum_limit PHP memory limit or above is recommended, especially if your site uses additional custom or contributed modules.', array('%memory_limit' => $memory_limit, '%memory_minimum_limit' => MINIMUM_PHP_MEMORY_LIMIT));
     }
 
     if (!empty($description)) {
@@ -226,8 +228,8 @@ function system_requirements($phase) {
 
   // Test settings.php file writability
   if ($phase == 'runtime') {
-    $conf_dir = drupal_verify_install_file(conf_path(), FILE_NOT_WRITABLE, 'dir');
-    $conf_file = drupal_verify_install_file(conf_path() . '/settings.php', FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE);
+    $conf_dir = verify_install_file(conf_path(), FILE_NOT_WRITABLE, 'dir');
+    $conf_file = verify_install_file(conf_path() . '/settings.php', FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE);
     if (!$conf_dir || !$conf_file) {
       $requirements['settings.php'] = array(
         'value' => $t('Not protected'),
@@ -368,9 +370,9 @@ function system_requirements($phase) {
 
     // Check installed modules.
     foreach (module_list() as $module) {
-      $updates = drupal_get_schema_versions($module);
+      $updates = get_schema_versions($module);
       if ($updates !== FALSE) {
-        $default = drupal_get_installed_schema_version($module);
+        $default = get_installed_schema_version($module);
         if (max($updates) > $default) {
           $requirements['update']['severity'] = REQUIREMENT_ERROR;
           $requirements['update']['value'] = $t('Out of date');
@@ -400,7 +402,7 @@ function system_requirements($phase) {
 
   // Display an error if a newly introduced dependency in a module is not resolved.
   if ($phase == 'update') {
-    $profile = drupal_get_profile();
+    $profile = get_profile();
     $files = system_rebuild_module_data();
     foreach ($files as $module => $file) {
       // Ignore disabled modules and install profiles.
@@ -430,8 +432,8 @@ function system_requirements($phase) {
         // Check for an incompatible version.
         $required_file = $files[$required_module];
         $required_name = $required_file->info['name'];
-        $version = str_replace(DRUPAL_CORE_COMPATIBILITY . '-', '', $required_file->info['version']);
-        $compatibility = drupal_check_incompatibility($requirement, $version);
+        $version = str_replace(CORE_COMPATIBILITY . '-', '', $required_file->info['version']);
+        $compatibility = check_incompatibility($requirement, $version);
         if ($compatibility) {
           $compatibility = rtrim(substr($compatibility, 2), ')');
           $requirements["$module-$required_module"] = array(
@@ -447,7 +449,7 @@ function system_requirements($phase) {
   }
 
   // Test Unicode library
-  include_once DRUPAL_ROOT . '/core/includes/unicode.inc';
+  include_once ROOT . '/core/includes/unicode.inc';
   $requirements = array_merge($requirements, unicode_requirements());
 
   if ($phase == 'runtime') {
@@ -467,12 +469,12 @@ function system_requirements($phase) {
     $requirements['update status']['title'] = $t('Update notifications');
 
     // Check that Drupal can issue HTTP requests.
-    if (variable_get('drupal_http_request_fails', TRUE) && !system_check_http_request()) {
+    if (variable_get('http_request_fails', TRUE) && !system_check_http_request()) {
       $requirements['http requests'] = array(
         'title' => $t('HTTP request status'),
         'value' => $t('Fails'),
         'severity' => REQUIREMENT_ERROR,
-        'description' => $t('Your system or network configuration does not allow Drupal to access web pages, resulting in reduced functionality. This could be due to your webserver configuration or PHP settings, and should be resolved in order to download information about available updates, fetch aggregator feeds, sign in via OpenID, or use other network-dependent services. If you are certain that Drupal can access web pages but you are still seeing this message, you may add <code>$conf[\'drupal_http_request_fails\'] = FALSE;</code> to the bottom of your settings.php file.'),
+        'description' => $t('Your system or network configuration does not allow Drupal to access web pages, resulting in reduced functionality. This could be due to your webserver configuration or PHP settings, and should be resolved in order to download information about available updates, fetch aggregator feeds, sign in via OpenID, or use other network-dependent services. If you are certain that Drupal can access web pages but you are still seeing this message, you may add <code>$conf[\'http_request_fails\'] = FALSE;</code> to the bottom of your settings.php file.'),
       );
     }
   }
@@ -485,10 +487,10 @@ function system_requirements($phase) {
  */
 function system_install() {
   // Create tables.
-  drupal_install_schema('system');
-  $versions = drupal_get_schema_versions('system');
+  install_schema('system');
+  $versions = get_schema_versions('system');
   $version = $versions ? max($versions) : SCHEMA_INSTALLED;
-  drupal_set_installed_schema_version('system', $version);
+  set_installed_schema_version('system', $version);
 
   // Clear out module list and hook implementation statics before calling
   // system_rebuild_theme_data().
@@ -507,7 +509,7 @@ function system_install() {
     ->execute();
 
   // Populate the cron key variable.
-  $cron_key = drupal_hash_base64(drupal_random_bytes(55));
+  $cron_key = hash_base64(random_bytes(55));
   variable_set('cron_key', $cron_key);
 }
 
@@ -824,7 +826,7 @@ function system_schema() {
         'default' => 0,
       ),
       'status' => array(
-        'description' => 'A field indicating the status of the file. Two status are defined in core: temporary (0) and permanent (1). Temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during a cron run.',
+        'description' => 'A field indicating the status of the file. Two status are defined in core: temporary (0) and permanent (1). Temporary files older than MAXIMUM_TEMP_FILE_AGE will be removed during a cron run.',
         'type' => 'int',
         'not null' => TRUE,
         'default' => 0,
diff --git a/core/modules/system/system.mail.inc b/core/modules/system/system.mail.inc
index 1ce9fc0..70309e8 100644
--- a/core/modules/system/system.mail.inc
+++ b/core/modules/system/system.mail.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -22,9 +23,9 @@ class DefaultMailSystem implements MailSystemInterface {
     // Join the body array into one string.
     $message['body'] = implode("\n\n", $message['body']);
     // Convert any HTML to plain-text.
-    $message['body'] = drupal_html_to_text($message['body']);
+    $message['body'] = html_to_text($message['body']);
     // Wrap the mail body for sending.
-    $message['body'] = drupal_wrap_mail($message['body']);
+    $message['body'] = wrap_mail($message['body']);
     return $message;
   }
 
@@ -32,7 +33,7 @@ class DefaultMailSystem implements MailSystemInterface {
    * Send an e-mail message, using Drupal variables and default settings.
    *
    * @see http://php.net/manual/en/function.mail.php
-   * @see drupal_mail()
+   * @see mail()
    *
    * @param $message
    *   A message array, as described in hook_mail_alter().
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index a5bfd10..7e10706 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use PDO, stdClass;
 
 /**
  * @file
@@ -8,49 +10,49 @@
 /**
  * Maximum age of temporary files in seconds.
  */
-const DRUPAL_MAXIMUM_TEMP_FILE_AGE = 21600;
+const MAXIMUM_TEMP_FILE_AGE = 21600;
 
 /**
  * Default interval for automatic cron executions in seconds.
  */
-const DRUPAL_CRON_DEFAULT_THRESHOLD = 10800;
+const CRON_DEFAULT_THRESHOLD = 10800;
 
 /**
  * New users will be set to the default time zone at registration.
  */
-const DRUPAL_USER_TIMEZONE_DEFAULT = 0;
+const USER_TIMEZONE_DEFAULT = 0;
 
 /**
  * New users will get an empty time zone at registration.
  */
-const DRUPAL_USER_TIMEZONE_EMPTY = 1;
+const USER_TIMEZONE_EMPTY = 1;
 
 /**
  * New users will select their own timezone at registration.
  */
-const DRUPAL_USER_TIMEZONE_SELECT = 2;
+const USER_TIMEZONE_SELECT = 2;
 
  /**
  * Disabled option on forms and settings
  */
-const DRUPAL_DISABLED = 0;
+const DISABLED = 0;
 
 /**
  * Optional option on forms and settings
  */
-const DRUPAL_OPTIONAL = 1;
+const OPTIONAL = 1;
 
 /**
  * Required option on forms and settings
  */
-const DRUPAL_REQUIRED = 2;
+const REQUIRED = 2;
 
 /**
  * Maximum number of values in a weight select element.
  *
  * If the number of values is over the maximum, a text field is used instead.
  */
-const DRUPAL_WEIGHT_SELECT_MAX = 100;
+const WEIGHT_SELECT_MAX = 100;
 
 /**
  * Return only visible regions.
@@ -149,7 +151,7 @@ function system_help($path, $arg) {
  * Implements hook_theme().
  */
 function system_theme() {
-  return array_merge(drupal_common_theme(), array(
+  return array_merge(common_theme(), array(
     'system_themes_page' => array(
       'variables' => array('theme_groups' => NULL),
       'file' => 'system.admin.inc',
@@ -309,21 +311,21 @@ function system_element_info() {
   );
   $types['html_tag'] = array(
     '#theme' => 'html_tag',
-    '#pre_render' => array('drupal_pre_render_conditional_comments'),
+    '#pre_render' => array('pre_render_conditional_comments'),
     '#attributes' => array(),
     '#value' => NULL,
   );
   $types['styles'] = array(
     '#items' => array(),
-    '#pre_render' => array('drupal_pre_render_styles'),
-    '#group_callback' => 'drupal_group_css',
-    '#aggregate_callback' => 'drupal_aggregate_css',
+    '#pre_render' => array('pre_render_styles'),
+    '#group_callback' => 'group_css',
+    '#aggregate_callback' => 'aggregate_css',
   );
   $types['scripts'] = array(
     '#items' => array(),
-    '#pre_render' => array('drupal_pre_render_scripts'),
-    '#group_callback' => 'drupal_group_js',
-    '#aggregate_callback' => 'drupal_aggregate_js',
+    '#pre_render' => array('pre_render_scripts'),
+    '#group_callback' => 'group_js',
+    '#aggregate_callback' => 'aggregate_js',
   );
 
   // Input elements.
@@ -475,7 +477,7 @@ function system_element_info() {
   // Form structure.
   $types['item'] = array(
     '#markup' => '',
-    '#pre_render' => array('drupal_pre_render_markup'),
+    '#pre_render' => array('pre_render_markup'),
     '#theme_wrappers' => array('form_element'),
   );
   $types['hidden'] = array(
@@ -488,10 +490,10 @@ function system_element_info() {
   );
   $types['markup'] = array(
     '#markup' => '',
-    '#pre_render' => array('drupal_pre_render_markup'),
+    '#pre_render' => array('pre_render_markup'),
   );
   $types['link'] = array(
-    '#pre_render' => array('drupal_pre_render_link', 'drupal_pre_render_markup'),
+    '#pre_render' => array('pre_render_link', 'pre_render_markup'),
   );
   $types['fieldset'] = array(
     '#collapsible' => FALSE,
@@ -640,7 +642,7 @@ function system_menu() {
   $items['admin/appearance/settings'] = array(
     'title' => 'Settings',
     'description' => 'Configure default and theme specific settings.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_theme_settings'),
     'access arguments' => array('administer themes'),
     'type' => MENU_LOCAL_TASK,
@@ -669,7 +671,7 @@ function system_menu() {
   $items['admin/modules'] = array(
     'title' => 'Modules',
     'description' => 'Extend site functionality.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_modules'),
     'access arguments' => array('administer modules'),
     'file' => 'system.admin.inc',
@@ -719,7 +721,7 @@ function system_menu() {
   );
   $items['admin/config/people/ip-blocking/delete/%blocked_ip'] = array(
     'title' => 'Delete IP address',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_ip_blocking_delete', 5),
     'access arguments' => array('block IP addresses'),
     'file' => 'system.admin.inc',
@@ -738,7 +740,7 @@ function system_menu() {
   $items['admin/config/media/file-system'] = array(
     'title' => 'File system',
     'description' => 'Tell Drupal where to store uploaded files and how they are accessed.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_file_system_settings'),
     'access arguments' => array('administer site configuration'),
     'weight' => -10,
@@ -747,7 +749,7 @@ function system_menu() {
   $items['admin/config/media/image-toolkit'] = array(
     'title' => 'Image toolkit',
     'description' => 'Choose which image toolkit to use if you have installed optional toolkits.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_image_toolkit_settings'),
     'access arguments' => array('administer site configuration'),
     'weight' => 20,
@@ -767,7 +769,7 @@ function system_menu() {
   $items['admin/config/services/rss-publishing'] = array(
     'title' => 'RSS publishing',
     'description' => 'Configure the site description, the number of items per feed and whether feeds should be titles/teasers/full-text.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_rss_feeds_settings'),
     'access arguments' => array('administer site configuration'),
     'file' => 'system.admin.inc',
@@ -786,7 +788,7 @@ function system_menu() {
   $items['admin/config/development/maintenance'] = array(
     'title' => 'Maintenance mode',
     'description' => 'Take the site offline for maintenance or bring it back online.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_site_maintenance_mode'),
     'access arguments' => array('administer site configuration'),
     'file' => 'system.admin.inc',
@@ -795,7 +797,7 @@ function system_menu() {
   $items['admin/config/development/performance'] = array(
     'title' => 'Performance',
     'description' => 'Enable or disable page caching for anonymous users and set CSS and JS bandwidth optimization options.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_performance_settings'),
     'access arguments' => array('administer site configuration'),
     'file' => 'system.admin.inc',
@@ -804,7 +806,7 @@ function system_menu() {
   $items['admin/config/development/logging'] = array(
     'title' => 'Logging and errors',
     'description' => "Settings for logging and alerts modules. Various modules can route Drupal's system events to different destinations, such as syslog, database, email, etc.",
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_logging_settings'),
     'access arguments' => array('administer site configuration'),
     'file' => 'system.admin.inc',
@@ -824,7 +826,7 @@ function system_menu() {
   $items['admin/config/regional/settings'] = array(
     'title' => 'Regional settings',
     'description' => "Settings for the site's default time zone and country.",
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_regional_settings'),
     'access arguments' => array('administer site configuration'),
     'weight' => -20,
@@ -833,7 +835,7 @@ function system_menu() {
   $items['admin/config/regional/date-time'] = array(
     'title' => 'Date and time',
     'description' => 'Configure display formats for date and time.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_date_time_settings'),
     'access arguments' => array('administer site configuration'),
     'weight' => -15,
@@ -842,7 +844,7 @@ function system_menu() {
   $items['admin/config/regional/date-time/types'] = array(
     'title' => 'Types',
     'description' => 'Configure display formats for date and time.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_date_time_settings'),
     'access arguments' => array('administer site configuration'),
     'type' => MENU_DEFAULT_LOCAL_TASK,
@@ -852,7 +854,7 @@ function system_menu() {
   $items['admin/config/regional/date-time/types/add'] = array(
     'title' => 'Add date type',
     'description' => 'Add new date type.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_add_date_format_type_form'),
     'access arguments' => array('administer site configuration'),
     'type' => MENU_LOCAL_ACTION,
@@ -862,7 +864,7 @@ function system_menu() {
   $items['admin/config/regional/date-time/types/%/delete'] = array(
     'title' => 'Delete date type',
     'description' => 'Allow users to delete a configured date type.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_delete_date_format_type_form', 5),
     'access arguments' => array('administer site configuration'),
     'file' => 'system.admin.inc',
@@ -880,7 +882,7 @@ function system_menu() {
     'title' => 'Add format',
     'description' => 'Allow users to add additional date formats.',
     'type' => MENU_LOCAL_ACTION,
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_configure_date_formats_form'),
     'access arguments' => array('administer site configuration'),
     'weight' => -10,
@@ -889,7 +891,7 @@ function system_menu() {
   $items['admin/config/regional/date-time/formats/%/edit'] = array(
     'title' => 'Edit date format',
     'description' => 'Allow users to edit a configured date format.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_configure_date_formats_form', 5),
     'access arguments' => array('administer site configuration'),
     'file' => 'system.admin.inc',
@@ -897,7 +899,7 @@ function system_menu() {
   $items['admin/config/regional/date-time/formats/%/delete'] = array(
     'title' => 'Delete date format',
     'description' => 'Allow users to delete a configured date format.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_date_delete_format_form', 5),
     'access arguments' => array('administer site configuration'),
     'file' => 'system.admin.inc',
@@ -923,7 +925,7 @@ function system_menu() {
   $items['admin/config/search/clean-urls'] = array(
     'title' => 'Clean URLs',
     'description' => 'Enable or disable clean URLs for your site.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_clean_url_settings'),
     'access arguments' => array('administer site configuration'),
     'file' => 'system.admin.inc',
@@ -931,7 +933,7 @@ function system_menu() {
   );
   $items['admin/config/search/clean-urls/check'] = array(
     'title' => 'Clean URL check',
-    'page callback' => 'drupal_json_output',
+    'page callback' => 'json_output',
     'page arguments' => array(array('status' => TRUE)),
     'access callback' => TRUE,
     'type' => MENU_CALLBACK,
@@ -965,7 +967,7 @@ function system_menu() {
   );
   $items['admin/config/system/actions/configure'] = array(
     'title' => 'Configure an advanced action',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_actions_configure'),
     'access arguments' => array('administer actions'),
     'type' => MENU_VISIBLE_IN_BREADCRUMB,
@@ -974,7 +976,7 @@ function system_menu() {
   $items['admin/config/system/actions/delete/%actions'] = array(
     'title' => 'Delete action',
     'description' => 'Delete an action.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_actions_delete_form', 5),
     'access arguments' => array('administer actions'),
     'file' => 'system.admin.inc',
@@ -989,7 +991,7 @@ function system_menu() {
   $items['admin/config/system/site-information'] = array(
     'title' => 'Site information',
     'description' => 'Change site name, e-mail address, slogan, default front page, and number of posts per page, error pages.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_site_information_settings'),
     'access arguments' => array('administer site configuration'),
     'file' => 'system.admin.inc',
@@ -998,7 +1000,7 @@ function system_menu() {
   $items['admin/config/system/cron'] = array(
     'title' => 'Cron',
     'description' => 'Manage automatic site maintenance tasks.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('system_cron_settings'),
     'access arguments' => array('administer site configuration'),
     'file' => 'system.admin.inc',
@@ -1084,7 +1086,7 @@ function _system_batch_theme() {
   // Retrieve the current state of the batch.
   $batch = &batch_get();
   if (!$batch && isset($_REQUEST['id'])) {
-    require_once DRUPAL_ROOT . '/core/includes/batch.inc';
+    require_once ROOT . '/core/includes/batch.inc';
     $batch = batch_load($_REQUEST['id']);
   }
   // Use the same theme as the page that started the batch.
@@ -1668,13 +1670,13 @@ function system_stream_wrappers() {
   $wrappers = array(
     'public' => array(
       'name' => t('Public files'),
-      'class' => 'DrupalPublicStreamWrapper',
+      'class' => 'PublicStreamWrapper',
       'description' => t('Public local files served by the webserver.'),
       'type' => STREAM_WRAPPERS_LOCAL_NORMAL,
     ),
     'temporary' => array(
       'name' => t('Temporary files'),
-      'class' => 'DrupalTemporaryStreamWrapper',
+      'class' => 'TemporaryStreamWrapper',
       'description' => t('Temporary local files for upload and previews.'),
       'type' => STREAM_WRAPPERS_LOCAL_HIDDEN,
     ),
@@ -1684,7 +1686,7 @@ function system_stream_wrappers() {
   if (variable_get('file_private_path', FALSE)) {
     $wrappers['private'] = array(
       'name' => t('Private files'),
-      'class' => 'DrupalPrivateStreamWrapper',
+      'class' => 'PrivateStreamWrapper',
       'description' => t('Private local files served by Drupal.'),
       'type' => STREAM_WRAPPERS_LOCAL_NORMAL,
     );
@@ -1710,7 +1712,7 @@ function blocked_ip_load($iid) {
  * Menu item access callback - only admin or enabled themes can be accessed.
  */
 function _system_themes_access($theme) {
-  return user_access('administer themes') && drupal_theme_access($theme);
+  return user_access('administer themes') && theme_access($theme);
 }
 
 /**
@@ -1738,7 +1740,7 @@ function _system_themes_access($theme) {
  * or to call system_authorized_init() and then redirect to authorize.php,
  * using the URL from system_authorized_get_url(). Redirecting yourself is
  * necessary when your authorized operation is being triggered by a form
- * submit handler, since calling drupal_goto() in a submit handler is a bad
+ * submit handler, since calling redirect() in a submit handler is a bad
  * idea, and you should instead set $form_state['redirect'].
  *
  * Once the SESSION is setup for the operation and the user is redirected to
@@ -1782,7 +1784,7 @@ function system_authorized_init($callback, $file, $arguments = array(), $page_ti
   // First, figure out what file transfer backends the site supports, and put
   // all of those in the SESSION so that authorize.php has access to all of
   // them via the class autoloader, even without a full bootstrap.
-  $_SESSION['authorize_filetransfer_info'] = drupal_get_filetransfer_info();
+  $_SESSION['authorize_filetransfer_info'] = get_filetransfer_info();
 
   // Now, define the callback to invoke.
   $_SESSION['authorize_operation'] = array(
@@ -1827,7 +1829,7 @@ function system_authorized_batch_processing_url() {
  */
 function system_authorized_run($callback, $file, $arguments = array(), $page_title = NULL) {
   system_authorized_init($callback, $file, $arguments, $page_title);
-  drupal_goto(system_authorized_get_url());
+  redirect(system_authorized_get_url());
 }
 
 /**
@@ -1898,14 +1900,14 @@ function system_filetransfer_info() {
  * Implements hook_init().
  */
 function system_init() {
-  $path = drupal_get_path('module', 'system');
+  $path = get_path('module', 'system');
   // Add the CSS for this module. These aren't in system.info, because they
   // need to be in the CSS_SYSTEM group rather than the CSS_DEFAULT group.
-  drupal_add_css($path . '/system.base.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));
+  add_css($path . '/system.base.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));
   if (path_is_admin(current_path())) {
-    drupal_add_css($path . '/system.admin.css', array('group' => CSS_SYSTEM));
+    add_css($path . '/system.admin.css', array('group' => CSS_SYSTEM));
   }
-  drupal_add_css($path . '/system.theme.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));
+  add_css($path . '/system.theme.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));
 
   // Ignore slave database servers for this request.
   //
@@ -1941,13 +1943,13 @@ function system_add_module_assets() {
     if (!empty($info['stylesheets'])) {
       foreach ($info['stylesheets'] as $media => $stylesheets) {
         foreach ($stylesheets as $stylesheet) {
-          drupal_add_css($stylesheet, array('every_page' => TRUE, 'media' => $media));
+          add_css($stylesheet, array('every_page' => TRUE, 'media' => $media));
         }
       }
     }
     if (!empty($info['scripts'])) {
       foreach ($info['scripts'] as $script) {
-        drupal_add_js($script, array('every_page' => TRUE));
+        add_js($script, array('every_page' => TRUE));
       }
     }
   }
@@ -1976,7 +1978,7 @@ function system_form_user_profile_form_alter(&$form, &$form_state) {
  * Implements hook_form_FORM_ID_alter().
  */
 function system_form_user_register_form_alter(&$form, &$form_state) {
-  if (variable_get('configurable_timezones', 1) && variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT) == DRUPAL_USER_TIMEZONE_SELECT) {
+  if (variable_get('configurable_timezones', 1) && variable_get('user_default_timezone', USER_TIMEZONE_DEFAULT) == USER_TIMEZONE_SELECT) {
     system_user_timezone($form, $form_state);
     return $form;
   }
@@ -1986,7 +1988,7 @@ function system_form_user_register_form_alter(&$form, &$form_state) {
  * Implements hook_user_insert().
  */
 function system_user_presave(&$edit, $account) {
-  if (variable_get('configurable_timezones', 1) && empty($account->timezone) && !variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT)) {
+  if (variable_get('configurable_timezones', 1) && empty($account->timezone) && !variable_get('user_default_timezone', USER_TIMEZONE_DEFAULT)) {
     $account->timezone = variable_get('date_default_timezone', '');
   }
 }
@@ -1998,7 +2000,7 @@ function system_user_presave(&$edit, $account) {
 function system_user_login(&$edit, $account) {
   // If the user has a NULL time zone, notify them to set a time zone.
   if (!$account->timezone && variable_get('configurable_timezones', 1) && variable_get('empty_timezone_message', 0)) {
-    drupal_set_message(t('Configure your <a href="@user-edit">account time zone setting</a>.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
+    set_message(t('Configure your <a href="@user-edit">account time zone setting</a>.', array('@user-edit' => url("user/$account->uid/edit", array('query' => get_destination(), 'fragment' => 'edit-timezone')))));
   }
 }
 
@@ -2025,7 +2027,7 @@ function system_user_timezone(&$form, &$form_state) {
   if (!isset($account->timezone) && $account->uid == $user->uid && empty($form_state['input']['timezone'])) {
     $form['timezone']['#description'] = t('Your time zone setting will be automatically detected if possible. Confirm the selection and click save.');
     $form['timezone']['timezone']['#attributes'] = array('class' => array('timezone-detect'));
-    drupal_add_js('core/misc/timezone.js');
+    add_js('core/misc/timezone.js');
   }
 }
 
@@ -2036,24 +2038,24 @@ function system_block_info() {
   $blocks['main'] = array(
     'info' => t('Main page content'),
      // Cached elsewhere.
-    'cache' => DRUPAL_NO_CACHE,
+    'cache' => NO_CACHE,
   );
   $blocks['powered-by'] = array(
     'info' => t('Powered by Drupal'),
     'weight' => '10',
-    'cache' => DRUPAL_NO_CACHE,
+    'cache' => NO_CACHE,
   );
   $blocks['help'] = array(
     'info' => t('System help'),
     'weight' => '5',
-    'cache' => DRUPAL_NO_CACHE,
+    'cache' => NO_CACHE,
   );
   // System-defined menu blocks.
   foreach (menu_list_system_menus() as $menu_name => $title) {
     $blocks[$menu_name]['info'] = t($title);
     // Menu blocks can't be cached because each menu item can have
     // a custom access callback. menu.inc manages its own caching.
-    $blocks[$menu_name]['cache'] = DRUPAL_NO_CACHE;
+    $blocks[$menu_name]['cache'] = NO_CACHE;
   }
   return $blocks;
 }
@@ -2069,7 +2071,7 @@ function system_block_view($delta = '') {
   switch ($delta) {
     case 'main':
       $block['subject'] = NULL;
-      $block['content'] = drupal_set_page_content();
+      $block['content'] = set_page_content();
       return $block;
     case 'powered-by':
       $block['subject'] = NULL;
@@ -2145,7 +2147,7 @@ function system_admin_menu_block($item) {
   $query
     ->fields('ml')
     // Weight should be taken from {menu_links}, not {menu_router}.
-    ->fields('m', array_diff(drupal_schema_fields_sql('menu_router'), array('weight')))
+    ->fields('m', array_diff(schema_fields_sql('menu_router'), array('weight')))
     ->condition('ml.plid', $item['mlid'])
     ->condition('ml.menu_name', $item['menu_name'])
     ->condition('ml.hidden', 0);
@@ -2367,10 +2369,10 @@ function system_get_info($type, $name = NULL) {
  */
 function _system_rebuild_module_data() {
   // Find modules
-  $modules = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.module$/', 'modules', 'name', 0);
+  $modules = system_listing('/^' . PHP_FUNCTION_PATTERN . '\.module$/', 'modules', 'name', 0);
 
   // Include the install profile in modules that are loaded.
-  $profile = drupal_get_profile();
+  $profile = get_profile();
   $modules[$profile] = new stdClass();
   $modules[$profile]->name = $profile;
   $modules[$profile]->uri = 'profiles/' . $profile . '/' . $profile . '.profile';
@@ -2385,7 +2387,7 @@ function _system_rebuild_module_data() {
     'description' => '',
     'package' => 'Other',
     'version' => NULL,
-    'php' => DRUPAL_MINIMUM_PHP,
+    'php' => MINIMUM_PHP,
     'files' => array(),
     'bootstrap' => 0,
   );
@@ -2397,7 +2399,7 @@ function _system_rebuild_module_data() {
     $modules[$key]->filename = $module->uri;
 
     // Look for the info file.
-    $module->info = drupal_parse_info_file(dirname($module->uri) . '/' . $module->name . '.info');
+    $module->info = parse_info_file(dirname($module->uri) . '/' . $module->name . '.info');
 
     // Skip modules that don't provide info.
     if (empty($module->info)) {
@@ -2426,7 +2428,7 @@ function _system_rebuild_module_data() {
     // Invoke hook_system_info_alter() to give installed modules a chance to
     // modify the data in the .info files if necessary.
     $type = 'module';
-    drupal_alter('system_info', $modules[$key]->info, $modules[$key], $type);
+    alter('system_info', $modules[$key]->info, $modules[$key], $type);
   }
 
   if (isset($modules[$profile])) {
@@ -2499,7 +2501,7 @@ function _system_update_bootstrap_status() {
  */
 function _system_rebuild_theme_data() {
   // Find themes
-  $themes = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info$/', 'themes');
+  $themes = system_listing('/^' . PHP_FUNCTION_PATTERN . '\.info$/', 'themes');
   // Allow modules to add further themes.
   if ($module_themes = module_invoke_all('system_theme_info')) {
     foreach ($module_themes as $name => $uri) {
@@ -2513,7 +2515,7 @@ function _system_rebuild_theme_data() {
   }
 
   // Find theme engines
-  $engines = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.engine$/', 'themes/engines');
+  $engines = system_listing('/^' . PHP_FUNCTION_PATTERN . '\.engine$/', 'themes/engines');
 
   // Set defaults for theme info.
   $defaults = array(
@@ -2532,7 +2534,7 @@ function _system_rebuild_theme_data() {
     'description' => '',
     'features' => _system_default_theme_features(),
     'screenshot' => 'screenshot.png',
-    'php' => DRUPAL_MINIMUM_PHP,
+    'php' => MINIMUM_PHP,
     'stylesheets' => array(),
     'scripts' => array(),
   );
@@ -2541,12 +2543,12 @@ function _system_rebuild_theme_data() {
   // Read info files for each theme
   foreach ($themes as $key => $theme) {
     $themes[$key]->filename = $theme->uri;
-    $themes[$key]->info = drupal_parse_info_file($theme->uri) + $defaults;
+    $themes[$key]->info = parse_info_file($theme->uri) + $defaults;
 
     // Invoke hook_system_info_alter() to give installed modules a chance to
     // modify the data in the .info files if necessary.
     $type = 'theme';
-    drupal_alter('system_info', $themes[$key]->info, $themes[$key], $type);
+    alter('system_info', $themes[$key]->info, $themes[$key], $type);
 
     if (!empty($themes[$key]->info['base theme'])) {
       $sub_themes[] = $key;
@@ -2785,7 +2787,7 @@ function system_settings_form($form) {
   $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
 
   if (!empty($_POST) && form_get_errors()) {
-    drupal_set_message(t('The settings have not been saved because of the errors.'), 'error');
+    set_message(t('The settings have not been saved because of the errors.'), 'error');
   }
   $form['#submit'][] = 'system_settings_form_submit';
   // By default, render the form using theme_system_settings_form().
@@ -2812,7 +2814,7 @@ function system_settings_form_submit($form, &$form_state) {
     variable_set($key, $value);
   }
 
-  drupal_set_message(t('The configuration options have been saved.'));
+  set_message(t('The configuration options have been saved.'));
 }
 
 /**
@@ -2886,7 +2888,7 @@ function confirm_form($form, $question, $path, $description = NULL, $yes = NULL,
     $options = array('path' => $path);
   }
 
-  drupal_set_title($question, PASS_THROUGH);
+  set_title($question, PASS_THROUGH);
 
   $form['#attributes']['class'][] = 'confirmation';
   $form['description'] = array('#markup' => $description);
@@ -2930,7 +2932,7 @@ function system_admin_compact_mode() {
  */
 function system_admin_compact_page($mode = 'off') {
   user_cookie_save(array('admin_compact_mode' => ($mode == 'on')));
-  drupal_goto();
+  redirect();
 }
 
 /**
@@ -2954,7 +2956,7 @@ function system_get_module_admin_tasks($module, $info) {
     $query
       ->fields('ml')
       // Weight should be taken from {menu_links}, not {menu_router}.
-      ->fields('m', array_diff(drupal_schema_fields_sql('menu_router'), array('weight')))
+      ->fields('m', array_diff(schema_fields_sql('menu_router'), array('weight')))
       ->condition('ml.link_path', 'admin/%', 'LIKE')
       ->condition('ml.hidden', 0, '>=')
       ->condition('ml.module', 'system')
@@ -3030,12 +3032,12 @@ function system_cron() {
     ->condition('expiration', REQUEST_TIME, '<')
     ->execute();
 
-  // Remove temporary files that are older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
+  // Remove temporary files that are older than MAXIMUM_TEMP_FILE_AGE.
   // Use separate placeholders for the status to avoid a bug in some versions
   // of PHP. See http://drupal.org/node/352956.
   $result = db_query('SELECT fid FROM {file_managed} WHERE status <> :permanent AND timestamp < :timestamp', array(
     ':permanent' => FILE_STATUS_PERMANENT,
-    ':timestamp' => REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE
+    ':timestamp' => REQUEST_TIME - MAXIMUM_TEMP_FILE_AGE
   ));
   foreach ($result as $row) {
     if ($file = file_load($row->fid)) {
@@ -3110,7 +3112,7 @@ function system_action_info() {
       'configurable' => FALSE,
       'triggers' => array('any'),
     ),
-    'system_goto_action' => array(
+    'system_redirect_action' => array(
       'type' => 'system',
       'label' => t('Redirect to URL'),
       'configurable' => TRUE,
@@ -3232,7 +3234,7 @@ function system_send_email_action($entity, $context) {
   }
   $params = array('context' => $context);
 
-  if (drupal_mail('system', 'action_send_email', $recipient, $language, $params)) {
+  if (mail('system', 'action_send_email', $recipient, $language, $params)) {
     watchdog('action', 'Sent email to %recipient', array('%recipient' => $recipient));
   }
   else {
@@ -3290,13 +3292,13 @@ function system_message_action(&$entity, $context = array()) {
   }
 
   $context['message'] = token_replace(filter_xss_admin($context['message']), $context);
-  drupal_set_message($context['message']);
+  set_message($context['message']);
 }
 
 /**
- * Settings form for system_goto_action().
+ * Settings form for system_redirect_action().
  */
-function system_goto_action_form($context) {
+function system_redirect_action_form($context) {
   $form['url'] = array(
     '#type' => 'textfield',
     '#title' => t('URL'),
@@ -3307,7 +3309,7 @@ function system_goto_action_form($context) {
   return $form;
 }
 
-function system_goto_action_submit($form, $form_state) {
+function system_redirect_action_submit($form, $form_state) {
   return array(
     'url' => $form_state['values']['url']
   );
@@ -3326,8 +3328,8 @@ function system_goto_action_submit($form, $form_state) {
  *
  * @ingroup actions
  */
-function system_goto_action($entity, $context) {
-  drupal_goto(token_replace($context['url'], $context));
+function system_redirect_action($entity, $context) {
+  redirect(token_replace($context['url'], $context));
 }
 
 /**
@@ -3368,20 +3370,20 @@ function system_time_zones($blank = NULL) {
 /**
  * Checks whether the server is capable of issuing HTTP requests.
  *
- * The function sets the drupal_http_request_fail system variable to TRUE if
- * drupal_http_request() does not work and then the system status report page
+ * The function sets the http_request_fail system variable to TRUE if
+ * http_request() does not work and then the system status report page
  * will contain an error.
  *
  * @return
  *  TRUE if this installation can issue HTTP requests.
  */
 function system_check_http_request() {
-  // Try to get the content of the front page via drupal_http_request().
-  $result = drupal_http_request(url('', array('absolute' => TRUE)), array('max_redirects' => 0));
+  // Try to get the content of the front page via http_request().
+  $result = http_request(url('', array('absolute' => TRUE)), array('max_redirects' => 0));
   // We only care that we get a http response - this means that Drupal
   // can make a http request.
   $works = isset($result->code) && ($result->code >= 100) && ($result->code < 600);
-  variable_set('drupal_http_request_fails', !$works);
+  variable_set('http_request_fails', !$works);
   return $works;
 }
 
@@ -3393,7 +3395,7 @@ function system_timezone($abbreviation = '', $offset = -1, $is_daylight_saving_t
   // interpreted as the empty string.
   $abbreviation = $abbreviation ? $abbreviation : '';
   $timezone = timezone_name_from_abbr($abbreviation, intval($offset), $is_daylight_saving_time);
-  drupal_json_output($timezone);
+  json_output($timezone);
 }
 
 /**
@@ -3413,10 +3415,10 @@ function theme_system_powered_by() {
 function theme_system_compact_link() {
   $output = '<div class="compact-link">';
   if (system_admin_compact_mode()) {
-    $output .= l(t('Show descriptions'), 'admin/compact/off', array('attributes' => array('title' => t('Expand layout to include descriptions.')), 'query' => drupal_get_destination()));
+    $output .= l(t('Show descriptions'), 'admin/compact/off', array('attributes' => array('title' => t('Expand layout to include descriptions.')), 'query' => get_destination()));
   }
   else {
-    $output .= l(t('Hide descriptions'), 'admin/compact/on', array('attributes' => array('title' => t('Compress layout by hiding descriptions.')), 'query' => drupal_get_destination()));
+    $output .= l(t('Hide descriptions'), 'admin/compact/on', array('attributes' => array('title' => t('Compress layout by hiding descriptions.')), 'query' => get_destination()));
   }
   $output .= '</div>';
 
@@ -3427,17 +3429,17 @@ function theme_system_compact_link() {
  * Implements hook_image_toolkits().
  */
 function system_image_toolkits() {
-  include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'system') . '/' . 'image.gd.inc';
+  include_once ROOT . '/' . get_path('module', 'system') . '/' . 'image.gd.inc';
   return array(
     'gd' => array(
       'title' => t('GD2 image manipulation toolkit'),
-      'available' => function_exists('image_gd_check_settings') && image_gd_check_settings(),
+      'available' => function_exists('Drupal\image_gd_check_settings') && image_gd_check_settings(),
     ),
   );
 }
 
 /**
- * Attempts to get a file using drupal_http_request and to store it locally.
+ * Attempts to get a file using http_request and to store it locally.
  *
  * @param $url
  *   The URL of the file to grab.
@@ -3467,25 +3469,25 @@ function system_image_toolkits() {
 function system_retrieve_file($url, $destination = NULL, $managed = FALSE, $replace = FILE_EXISTS_RENAME) {
   $parsed_url = parse_url($url);
   if (!isset($destination)) {
-    $path = file_build_uri(drupal_basename($parsed_url['path']));
+    $path = file_build_uri(basename($parsed_url['path']));
   }
   else {
     if (is_dir(drupal_realpath($destination))) {
       // Prevent URIs with triple slashes when glueing parts together.
-      $path = str_replace('///', '//', "$destination/") . drupal_basename($parsed_url['path']);
+      $path = str_replace('///', '//', "$destination/") . basename($parsed_url['path']);
     }
     else {
       $path = $destination;
     }
   }
-  $result = drupal_http_request($url);
+  $result = http_request($url);
   if ($result->code != 200) {
-    drupal_set_message(t('HTTP error @errorcode occurred when trying to fetch @remote.', array('@errorcode' => $result->code, '@remote' => $url)), 'error');
+    set_message(t('HTTP error @errorcode occurred when trying to fetch @remote.', array('@errorcode' => $result->code, '@remote' => $url)), 'error');
     return FALSE;
   }
   $local = $managed ? file_save_data($result->data, $path, $replace) : file_unmanaged_save_data($result->data, $path, $replace);
   if (!$local) {
-    drupal_set_message(t('@remote could not be saved to @path.', array('@remote' => $url, '@path' => $path)), 'error');
+    set_message(t('@remote could not be saved to @path.', array('@remote' => $url, '@path' => $path)), 'error');
   }
 
   return $local;
@@ -3513,10 +3515,10 @@ function system_run_automated_cron() {
   // If the site is not fully installed, suppress the automated cron run.
   // Otherwise it could be triggered prematurely by Ajax requests during
   // installation.
-  if (($threshold = variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD)) > 0 && variable_get('install_task') == 'done') {
+  if (($threshold = variable_get('cron_safe_threshold', CRON_DEFAULT_THRESHOLD)) > 0 && variable_get('install_task') == 'done') {
     $cron_last = variable_get('cron_last', NULL);
     if (!isset($cron_last) || (REQUEST_TIME - $cron_last > $threshold)) {
-      drupal_cron_run();
+      cron_run();
     }
   }
 }
@@ -3567,7 +3569,7 @@ function system_date_format_types() {
  * Implements hook_date_formats().
  */
 function system_date_formats() {
-  include_once DRUPAL_ROOT . '/core/includes/date.inc';
+  include_once ROOT . '/core/includes/date.inc';
   return system_default_date_formats();
 }
 
@@ -3627,7 +3629,7 @@ function system_get_date_format($dfid) {
  * Resets the database cache of date formats and saves all new date formats.
  */
 function system_date_formats_rebuild() {
-  drupal_static_reset('system_get_date_formats');
+  drupal_static_reset('Drupal\system_get_date_formats');
   $date_formats = system_get_date_formats(NULL);
 
   foreach ($date_formats as $type => $formats) {
@@ -3637,7 +3639,7 @@ function system_date_formats_rebuild() {
   }
 
   // Rebuild configured date formats locale list.
-  drupal_static_reset('system_date_format_locale');
+  drupal_static_reset('Drupal\system_date_format_locale');
   system_date_format_locale();
 
   _system_date_formats_build();
@@ -3738,7 +3740,7 @@ function _system_date_format_types_build() {
   }
 
   // Allow other modules to modify these date types.
-  drupal_alter('date_format_types', $types);
+  alter('date_format_types', $types);
 
   return $types;
 }
@@ -3825,7 +3827,7 @@ function _system_date_formats_build() {
   }
 
   // Allow other modules to modify these formats.
-  drupal_alter('date_formats', $date_formats);
+  alter('date_formats', $date_formats);
 
   return $date_formats;
 }
@@ -3850,10 +3852,10 @@ function system_date_format_type_save($type) {
 
   // Update date_format table.
   if (!empty($type['is_new'])) {
-    drupal_write_record('date_format_type', $info);
+    write_record('date_format_type', $info);
   }
   else {
-    drupal_write_record('date_format_type', $info, 'type');
+    write_record('date_format_type', $info, 'type');
   }
 }
 
@@ -3900,11 +3902,11 @@ function system_date_format_save($date_format, $dfid = 0) {
 
   // Update date_format table.
   if (!empty($date_format['is_new'])) {
-    drupal_write_record('date_formats', $info);
+    write_record('date_formats', $info);
   }
   else {
     $keys = ($dfid ? array('dfid') : array('format', 'type'));
-    drupal_write_record('date_formats', $info, $keys);
+    write_record('date_formats', $info, $keys);
   }
 
   // Retrieve an array of language objects for enabled languages.
@@ -3922,7 +3924,7 @@ function system_date_format_save($date_format, $dfid = 0) {
         $is_existing = (bool) db_query_range('SELECT 1 FROM {date_format_locale} WHERE type = :type AND language = :language', 0, 1, array(':type' => $date_format['type'], ':language' => $langcode))->fetchField();
         if (!$is_existing) {
           $locale_format['language'] = $langcode;
-          drupal_write_record('date_format_locale', $locale_format);
+          write_record('date_format_locale', $locale_format);
         }
       }
     }
@@ -3971,7 +3973,7 @@ function system_archiver_info() {
  * @ingroup themeable
  */
 function theme_confirm_form($variables) {
-  return drupal_render_children($variables['form']);
+  return render_children($variables['form']);
 }
 
 /**
@@ -3987,7 +3989,7 @@ function theme_confirm_form($variables) {
  * @ingroup themeable
  */
 function theme_system_settings_form($variables) {
-  return drupal_render_children($variables['form']);
+  return render_children($variables['form']);
 }
 
 /**
@@ -4014,7 +4016,7 @@ function theme_exposed_filters($variables) {
     $output .= theme('item_list', array('items' => $items, 'attributes' => array('class' => array('clearfix', 'current-filters'))));
   }
 
-  $output .= drupal_render_children($form);
+  $output .= render_children($form);
 
   return '<div class="exposed-filters">' . $output . '</div>';
 }
diff --git a/core/modules/system/system.queue.inc b/core/modules/system/system.queue.inc
index 00d3940..9d05505 100644
--- a/core/modules/system/system.queue.inc
+++ b/core/modules/system/system.queue.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * @file
@@ -14,26 +16,26 @@
  * The system tries to ensure that only one consumer can process an item.
  *
  * Before a queue can be used it needs to be created by
- * DrupalQueueInterface::createQueue().
+ * QueueInterface::createQueue().
  *
  * Items can be added to the queue by passing an arbitrary data object to
- * DrupalQueueInterface::createItem().
+ * QueueInterface::createItem().
  *
- * To process an item, call DrupalQueueInterface::claimItem() and specify how
+ * To process an item, call QueueInterface::claimItem() and specify how
  * long you want to have a lease for working on that item. When finished
  * processing, the item needs to be deleted by calling
- * DrupalQueueInterface::deleteItem(). If the consumer dies, the item will be
- * made available again by the DrupalQueueInterface implementation once the
+ * QueueInterface::deleteItem(). If the consumer dies, the item will be
+ * made available again by the QueueInterface implementation once the
  * lease expires. Another consumer will then be able to receive it when calling
- * DrupalQueueInterface::claimItem(). Due to this, the processing code should
+ * QueueInterface::claimItem(). Due to this, the processing code should
  * be aware that an item might be handed over for processing more than once.
  *
- * The $item object used by the DrupalQueueInterface can contain arbitrary
+ * The $item object used by the QueueInterface can contain arbitrary
  * metadata depending on the implementation. Systems using the interface should
  * only rely on the data property which will contain the information passed to
- * DrupalQueueInterface::createItem(). The full queue item returned by
- * DrupalQueueInterface::claimItem() needs to be passed to
- * DrupalQueueInterface::deleteItem() once processing is completed.
+ * QueueInterface::createItem(). The full queue item returned by
+ * QueueInterface::claimItem() needs to be passed to
+ * QueueInterface::deleteItem() once processing is completed.
  *
  * There are two kinds of queue backends available: reliable, which preserves
  * the order of messages and guarantees that every item will be executed at
@@ -57,7 +59,7 @@
 /**
  * Factory class for interacting with queues.
  */
-class DrupalQueue {
+class Queue {
   /**
    * Returns the queue object for a given name.
    *
@@ -85,9 +87,10 @@ class DrupalQueue {
       if (!$class) {
         $class = variable_get('queue_default_class', 'SystemQueue');
       }
+      $class = 'Drupal\\' . $class;
       $object = new $class($name);
-      if ($reliable && !$object instanceof DrupalReliableQueueInterface) {
-        $class = variable_get('queue_default_reliable_class', 'SystemQueue');
+      if ($reliable && !$object instanceof ReliableQueueInterface) {
+        $class = 'Drupal\\' . variable_get('queue_default_reliable_class', 'SystemQueue');
         $object = new $class($name);
       }
       $queues[$name] = $object;
@@ -96,7 +99,7 @@ class DrupalQueue {
   }
 }
 
-interface DrupalQueueInterface {
+interface QueueInterface {
   /**
    * Start working with a queue.
    *
@@ -158,7 +161,7 @@ interface DrupalQueueInterface {
    * Delete a finished item from the queue.
    *
    * @param $item
-   *   The item returned by DrupalQueueInterface::claimItem().
+   *   The item returned by QueueInterface::claimItem().
    */
   public function deleteItem($item);
 
@@ -196,13 +199,13 @@ interface DrupalQueueInterface {
  * Classes implementing this interface preserve the order of messages and
  * guarantee that every item will be executed at least once.
  */
-interface DrupalReliableQueueInterface extends DrupalQueueInterface {
+interface ReliableQueueInterface extends QueueInterface {
 }
 
 /**
  * Default queue implementation.
  */
-class SystemQueue implements DrupalReliableQueueInterface {
+class SystemQueue implements ReliableQueueInterface {
   /**
    * The name of the queue this instance is working with.
    *
@@ -215,8 +218,8 @@ class SystemQueue implements DrupalReliableQueueInterface {
   }
 
   public function createItem($data) {
-    // During a Drupal 6.x to 8.x update, drupal_get_schema() does not contain
-    // the queue table yet, so we cannot rely on drupal_write_record().
+    // During a Drupal 6.x to 8.x update, get_schema() does not contain
+    // the queue table yet, so we cannot rely on write_record().
     $query = db_insert('queue')
       ->fields(array(
         'name' => $this->name,
@@ -300,7 +303,7 @@ class SystemQueue implements DrupalReliableQueueInterface {
  * interface. The queue data resides in memory. It should only be used for
  * items that will be queued and dequeued within a given page request.
  */
-class MemoryQueue implements DrupalQueueInterface {
+class MemoryQueue implements QueueInterface {
   /**
    * The queue data.
    *
diff --git a/core/modules/system/system.tar.inc b/core/modules/system/system.tar.inc
index 32bf7f0..c7735b0 100644
--- a/core/modules/system/system.tar.inc
+++ b/core/modules/system/system.tar.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
 
 /**
diff --git a/core/modules/system/system.test b/core/modules/system/system.test
index 185a680..c387cc7 100644
--- a/core/modules/system/system.test
+++ b/core/modules/system/system.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -8,7 +10,7 @@
 /**
  * Helper class for module test cases.
  */
-class ModuleTestCase extends DrupalWebTestCase {
+class ModuleTestCase extends WebTestCase {
   protected $admin_user;
 
   function setUp() {
@@ -43,7 +45,7 @@ class ModuleTestCase extends DrupalWebTestCase {
    *   The name of the module.
    */
   function assertModuleTablesExist($module) {
-    $tables = array_keys(drupal_get_schema_unprocessed($module));
+    $tables = array_keys(get_schema_unprocessed($module));
     $tables_exist = TRUE;
     foreach ($tables as $table) {
       if (!db_table_exists($table)) {
@@ -60,7 +62,7 @@ class ModuleTestCase extends DrupalWebTestCase {
    *   The name of the module.
    */
   function assertModuleTablesDoNotExist($module) {
-    $tables = array_keys(drupal_get_schema_unprocessed($module));
+    $tables = array_keys(get_schema_unprocessed($module));
     $tables_exist = FALSE;
     foreach ($tables as $table) {
       if (db_table_exists($table)) {
@@ -161,7 +163,7 @@ class EnableDisableTestCase extends ModuleTestCase {
    }
 
    // Set a variable so that the hook implementations in system_test.module
-   // will display messages via drupal_set_message().
+   // will display messages via set_message().
    variable_set('test_verbose_module_hooks', TRUE);
 
     // Throughout this test, some modules may be automatically enabled (due to
@@ -620,7 +622,7 @@ class ModuleRequiredTestCase extends ModuleTestCase {
   }
 }
 
-class IPAddressBlockingTestCase extends DrupalWebTestCase {
+class IPAddressBlockingTestCase extends WebTestCase {
   protected $blocking_user;
 
   /**
@@ -699,7 +701,7 @@ class IPAddressBlockingTestCase extends DrupalWebTestCase {
   }
 }
 
-class CronRunTestCase extends DrupalWebTestCase {
+class CronRunTestCase extends WebTestCase {
   /**
    * Implement getInfo().
    */
@@ -781,7 +783,7 @@ class CronRunTestCase extends DrupalWebTestCase {
    * timestamp.
    */
   function testTempFileCleanup() {
-    // Temporary file that is older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
+    // Temporary file that is older than MAXIMUM_TEMP_FILE_AGE.
     $temp_old = file_save_data('');
     db_update('file_managed')
       ->fields(array(
@@ -792,7 +794,7 @@ class CronRunTestCase extends DrupalWebTestCase {
       ->execute();
     $this->assertTrue(file_exists($temp_old->uri), t('Old temp file was created correctly.'));
 
-    // Temporary file that is less than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
+    // Temporary file that is less than MAXIMUM_TEMP_FILE_AGE.
     $temp_new = file_save_data('');
     db_update('file_managed')
       ->fields(array('status' => 0))
@@ -800,7 +802,7 @@ class CronRunTestCase extends DrupalWebTestCase {
       ->execute();
     $this->assertTrue(file_exists($temp_new->uri), t('New temp file was created correctly.'));
 
-    // Permanent file that is older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
+    // Permanent file that is older than MAXIMUM_TEMP_FILE_AGE.
     $perm_old = file_save_data('');
     db_update('file_managed')
       ->fields(array('timestamp' => 1))
@@ -808,7 +810,7 @@ class CronRunTestCase extends DrupalWebTestCase {
       ->execute();
     $this->assertTrue(file_exists($perm_old->uri), t('Old permanent file was created correctly.'));
 
-    // Permanent file that is newer than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
+    // Permanent file that is newer than MAXIMUM_TEMP_FILE_AGE.
     $perm_new = file_save_data('');
     $this->assertTrue(file_exists($perm_new->uri), t('New permanent file was created correctly.'));
 
@@ -834,7 +836,7 @@ class CronRunTestCase extends DrupalWebTestCase {
   }
 }
 
-class AdminMetaTagTestCase extends DrupalWebTestCase {
+class AdminMetaTagTestCase extends WebTestCase {
   /**
    * Implement getInfo().
    */
@@ -860,7 +862,7 @@ class AdminMetaTagTestCase extends DrupalWebTestCase {
 /**
  * Tests custom access denied functionality.
  */
-class AccessDeniedTestCase extends DrupalWebTestCase {
+class AccessDeniedTestCase extends WebTestCase {
   protected $admin_user;
 
   public static function getInfo() {
@@ -934,7 +936,7 @@ class AccessDeniedTestCase extends DrupalWebTestCase {
   }
 }
 
-class PageNotFoundTestCase extends DrupalWebTestCase {
+class PageNotFoundTestCase extends WebTestCase {
   protected $admin_user;
 
   /**
@@ -980,7 +982,7 @@ class PageNotFoundTestCase extends DrupalWebTestCase {
 /**
  * Tests site maintenance functionality.
  */
-class SiteMaintenanceTestCase extends DrupalWebTestCase {
+class SiteMaintenanceTestCase extends WebTestCase {
   protected $admin_user;
 
   public static function getInfo() {
@@ -1081,7 +1083,7 @@ class SiteMaintenanceTestCase extends DrupalWebTestCase {
 /**
  * Tests generic date and time handling capabilities of Drupal.
  */
-class DateTimeFunctionalTest extends DrupalWebTestCase {
+class DateTimeFunctionalTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Date and time',
@@ -1274,7 +1276,7 @@ class DateTimeFunctionalTest extends DrupalWebTestCase {
   }
 }
 
-class PageTitleFiltering extends DrupalWebTestCase {
+class PageTitleFiltering extends WebTestCase {
   protected $content_user;
   protected $saved_title;
 
@@ -1284,7 +1286,7 @@ class PageTitleFiltering extends DrupalWebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'HTML in page titles',
-      'description' => 'Tests correct handling or conversion by drupal_set_title() and drupal_get_title() and checks the correct escaping of site name and slogan.',
+      'description' => 'Tests correct handling or conversion by set_title() and get_title() and checks the correct escaping of site name and slogan.',
       'group' => 'System'
     );
   }
@@ -1297,7 +1299,7 @@ class PageTitleFiltering extends DrupalWebTestCase {
 
     $this->content_user = $this->drupalCreateUser(array('create page content', 'access content', 'administer themes', 'administer site configuration'));
     $this->drupalLogin($this->content_user);
-    $this->saved_title = drupal_get_title();
+    $this->saved_title = get_title();
   }
 
   /**
@@ -1305,24 +1307,24 @@ class PageTitleFiltering extends DrupalWebTestCase {
    */
   function tearDown() {
     // Restore the page title.
-    drupal_set_title($this->saved_title, PASS_THROUGH);
+    set_title($this->saved_title, PASS_THROUGH);
 
     parent::tearDown();
   }
 
   /**
-   * Tests the handling of HTML by drupal_set_title() and drupal_get_title()
+   * Tests the handling of HTML by set_title() and get_title()
    */
   function testTitleTags() {
     $title = "string with <em>HTML</em>";
-    // drupal_set_title's $filter is CHECK_PLAIN by default, so the title should be
+    // set_title's $filter is CHECK_PLAIN by default, so the title should be
     // returned with check_plain().
-    drupal_set_title($title, CHECK_PLAIN);
-    $this->assertTrue(strpos(drupal_get_title(), '<em>') === FALSE, t('Tags in title converted to entities when $output is CHECK_PLAIN.'));
-    // drupal_set_title's $filter is passed as PASS_THROUGH, so the title should be
+    set_title($title, CHECK_PLAIN);
+    $this->assertTrue(strpos(get_title(), '<em>') === FALSE, t('Tags in title converted to entities when $output is CHECK_PLAIN.'));
+    // set_title's $filter is passed as PASS_THROUGH, so the title should be
     // returned with HTML.
-    drupal_set_title($title, PASS_THROUGH);
-    $this->assertTrue(strpos(drupal_get_title(), '<em>') !== FALSE, t('Tags in title are not converted to entities when $output is PASS_THROUGH.'));
+    set_title($title, PASS_THROUGH);
+    $this->assertTrue(strpos(get_title(), '<em>') !== FALSE, t('Tags in title are not converted to entities when $output is PASS_THROUGH.'));
     // Generate node content.
     $langcode = LANGUAGE_NONE;
     $edit = array(
@@ -1369,7 +1371,7 @@ class PageTitleFiltering extends DrupalWebTestCase {
 
     // Test the title.
     $this->assertNoRaw($title, 'Check for the unfiltered version of the title.');
-    // Adding </title> so we do not test the escaped version from drupal_set_title().
+    // Adding </title> so we do not test the escaped version from set_title().
     $this->assertRaw($title_filtered . '</title>', 'Check for the filtered version of the title.');
 
     // Test the slogan.
@@ -1381,7 +1383,7 @@ class PageTitleFiltering extends DrupalWebTestCase {
 /**
  * Test front page functionality and administration.
  */
-class FrontPageTestCase extends DrupalWebTestCase {
+class FrontPageTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1433,7 +1435,7 @@ class FrontPageTestCase extends DrupalWebTestCase {
   }
 }
 
-class SystemBlockTestCase extends DrupalWebTestCase {
+class SystemBlockTestCase extends WebTestCase {
   protected $profile = 'testing';
 
   public static function getInfo() {
@@ -1502,7 +1504,7 @@ class SystemBlockTestCase extends DrupalWebTestCase {
 /**
  * Test main content rendering fallback provided by system module.
  */
-class SystemMainContentFallback extends DrupalWebTestCase {
+class SystemMainContentFallback extends WebTestCase {
   protected $admin_user;
   protected $web_user;
 
@@ -1586,7 +1588,7 @@ class SystemMainContentFallback extends DrupalWebTestCase {
 /**
  * Tests for the theme interface functionality.
  */
-class SystemThemeFunctionalTest extends DrupalWebTestCase {
+class SystemThemeFunctionalTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Theme interface functionality',
@@ -1708,7 +1710,7 @@ class SystemThemeFunctionalTest extends DrupalWebTestCase {
 /**
  * Test the basic queue functionality.
  */
-class QueueTestCase extends DrupalWebTestCase {
+class QueueTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Queue functionality',
@@ -1722,9 +1724,9 @@ class QueueTestCase extends DrupalWebTestCase {
    */
   function testQueue() {
     // Create two queues.
-    $queue1 = DrupalQueue::get($this->randomName());
+    $queue1 = Queue::get($this->randomName());
     $queue1->createQueue();
-    $queue2 = DrupalQueue::get($this->randomName());
+    $queue2 = Queue::get($this->randomName());
     $queue2->createQueue();
 
     // Create four items.
@@ -1799,7 +1801,7 @@ class QueueTestCase extends DrupalWebTestCase {
 /**
  * Test token replacement in strings.
  */
-class TokenReplaceTestCase extends DrupalWebTestCase {
+class TokenReplaceTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Token replacement',
@@ -1952,7 +1954,7 @@ class TokenReplaceTestCase extends DrupalWebTestCase {
   }
 }
 
-class InfoFileParserTestCase extends DrupalUnitTestCase {
+class InfoFileParserTestCase extends UnitTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Info file format parser',
@@ -1962,7 +1964,7 @@ class InfoFileParserTestCase extends DrupalUnitTestCase {
   }
 
   /**
-   * Test drupal_parse_info_format().
+   * Test parse_info_format().
    */
   function testDrupalParseInfoFormat() {
     $config = '
@@ -2009,7 +2011,7 @@ array_space[a b] = Value';
       ),
     );
 
-    $parsed = drupal_parse_info_format($config);
+    $parsed = parse_info_format($config);
 
     $this->assertEqual($parsed['simple'], $expected['simple'], t('Set a simple value.'));
     $this->assertEqual($parsed['quoted'], $expected['quoted'], t('Set a simple value in quotes.'));
@@ -2026,7 +2028,7 @@ array_space[a b] = Value';
 /**
  * Tests the effectiveness of hook_system_info_alter().
  */
-class SystemInfoAlterTestCase extends DrupalWebTestCase {
+class SystemInfoAlterTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'System info alter',
@@ -2044,7 +2046,7 @@ class SystemInfoAlterTestCase extends DrupalWebTestCase {
     // Enable our test module. Flush all caches, which we assert is the only
     // thing necessary to use the rebuilt {system}.info.
     module_enable(array('module_test'), FALSE);
-    drupal_flush_all_caches();
+    flush_all_caches();
     $this->assertTrue(module_exists('module_test'), t('Test module is enabled.'));
 
     $info = $this->getSystemInfo('seven', 'theme');
@@ -2059,7 +2061,7 @@ class SystemInfoAlterTestCase extends DrupalWebTestCase {
 
     // Disable the module and verify that {system}.info is rebuilt without it.
     module_disable(array('module_test'), FALSE);
-    drupal_flush_all_caches();
+    flush_all_caches();
     $this->assertFalse(module_exists('module_test'), t('Test module is disabled.'));
 
     $info = $this->getSystemInfo('seven', 'theme');
@@ -2093,7 +2095,7 @@ class SystemInfoAlterTestCase extends DrupalWebTestCase {
 /**
  * Tests for the update system functionality.
  */
-class UpdateScriptFunctionalTest extends DrupalWebTestCase {
+class UpdateScriptFunctionalTest extends WebTestCase {
   private $update_url;
   private $update_user;
 
@@ -2134,7 +2136,7 @@ class UpdateScriptFunctionalTest extends DrupalWebTestCase {
     // Access the update page as user 1.
     $user1 = user_load(1);
     $user1->pass_raw = user_password();
-    require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'core/includes/password.inc');
+    require_once ROOT . '/' . variable_get('password_inc', 'core/includes/password.inc');
     $user1->pass = user_hash_password(trim($user1->pass_raw));
     db_query("UPDATE {users} SET pass = :pass WHERE uid = :uid", array(':pass' => $user1->pass, ':uid' => $user1->uid));
     $this->drupalLogin($user1);
@@ -2163,7 +2165,7 @@ class UpdateScriptFunctionalTest extends DrupalWebTestCase {
     // First, run this test with pending updates to make sure they can be run
     // successfully.
     variable_set('update_script_test_requirement_type', REQUIREMENT_WARNING);
-    drupal_set_installed_schema_version('update_script_test', drupal_get_installed_schema_version('update_script_test') - 1);
+    set_installed_schema_version('update_script_test', get_installed_schema_version('update_script_test') - 1);
     $this->drupalGet($this->update_url, array('external' => TRUE));
     $this->assertText('This is a requirements warning provided by the update_script_test module.');
     $this->clickLink('try again');
@@ -2212,7 +2214,7 @@ class UpdateScriptFunctionalTest extends DrupalWebTestCase {
 /**
  * Functional tests for the flood control mechanism.
  */
-class FloodFunctionalTest extends DrupalWebTestCase {
+class FloodFunctionalTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Flood control mechanism',
@@ -2250,7 +2252,7 @@ class FloodFunctionalTest extends DrupalWebTestCase {
 /**
  * Test HTTP file downloading capability.
  */
-class RetrieveFileTestCase extends DrupalWebTestCase {
+class RetrieveFileTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'HTTP file retrieval',
@@ -2299,7 +2301,7 @@ class RetrieveFileTestCase extends DrupalWebTestCase {
 /**
  * Functional tests shutdown functions.
  */
-class ShutdownFunctionsTest extends DrupalWebTestCase {
+class ShutdownFunctionsTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Shutdown functions',
@@ -2322,7 +2324,7 @@ class ShutdownFunctionsTest extends DrupalWebTestCase {
     $this->assertText(t('First shutdown function, arg1 : @arg1, arg2: @arg2', array('@arg1' => $arg1, '@arg2' => $arg2)));
     $this->assertText(t('Second shutdown function, arg1 : @arg1, arg2: @arg2', array('@arg1' => $arg1, '@arg2' => $arg2)));
 
-    // Make sure exceptions displayed through _drupal_render_exception_safe()
+    // Make sure exceptions displayed through _render_exception_safe()
     // are correctly escaped.
     $this->assertRaw('Drupal is &amp;lt;blink&amp;gt;awesome&amp;lt;/blink&amp;gt;.');
   }
@@ -2331,7 +2333,7 @@ class ShutdownFunctionsTest extends DrupalWebTestCase {
 /**
  * Tests administrative overview pages.
  */
-class SystemAdminTestCase extends DrupalWebTestCase {
+class SystemAdminTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Administrative pages',
@@ -2444,7 +2446,7 @@ class SystemAdminTestCase extends DrupalWebTestCase {
 /**
  * Tests authorize.php and related hooks.
  */
-class SystemAuthorizeCase extends DrupalWebTestCase {
+class SystemAuthorizeCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Authorize API',
@@ -2497,7 +2499,7 @@ class SystemAuthorizeCase extends DrupalWebTestCase {
 /**
  * Test the handling of requests containing 'index.php'.
  */
-class SystemIndexPhpTest extends DrupalWebTestCase {
+class SystemIndexPhpTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Index.php handling',
@@ -2530,7 +2532,7 @@ class SystemIndexPhpTest extends DrupalWebTestCase {
 /**
  * Tests uuid.inc and related functions.
  */
-class UuidUnitTestCase extends DrupalUnitTestCase {
+class UuidUnitTestCase extends UnitTestCase {
 
   /**
    * The UUID object to be used for generating UUIDs.
diff --git a/core/modules/system/system.tokens.inc b/core/modules/system/system.tokens.inc
index fa95661..7404994 100644
--- a/core/modules/system/system.tokens.inc
+++ b/core/modules/system/system.tokens.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/system/system.updater.inc b/core/modules/system/system.updater.inc
index 84c1752..0d96627 100644
--- a/core/modules/system/system.updater.inc
+++ b/core/modules/system/system.updater.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -9,14 +10,14 @@
 /**
  * Class for updating modules using FileTransfer classes via authorize.php.
  */
-class ModuleUpdater extends Updater implements DrupalUpdaterInterface {
+class ModuleUpdater extends Updater implements UpdaterInterface {
 
   /**
    * Return the directory where a module should be installed.
    *
-   * If the module is already installed, drupal_get_path() will return
+   * If the module is already installed, get_path() will return
    * a valid path and we should install it there (although we need to use an
-   * absolute path, so we prepend DRUPAL_ROOT). If we're installing a new
+   * absolute path, so we prepend ROOT). If we're installing a new
    * module, we always want it to go into sites/all/modules, since that's
    * where all the documentation recommends users install their modules, and
    * there's no way that can conflict on a multi-site installation, since
@@ -24,17 +25,17 @@ class ModuleUpdater extends Updater implements DrupalUpdaterInterface {
    * found on your system, and if there was a copy in sites/all, we'd see it.
    */
   public function getInstallDirectory() {
-    if ($relative_path = drupal_get_path('module', $this->name)) {
+    if ($relative_path = get_path('module', $this->name)) {
       $relative_path = dirname($relative_path);
     }
     else {
       $relative_path = 'sites/all/modules';
     }
-    return DRUPAL_ROOT . '/' . $relative_path;
+    return ROOT . '/' . $relative_path;
   }
 
   public function isInstalled() {
-    return (bool) drupal_get_path('module', $this->name);
+    return (bool) get_path('module', $this->name);
   }
 
   public static function canUpdateDirectory($directory) {
@@ -45,22 +46,22 @@ class ModuleUpdater extends Updater implements DrupalUpdaterInterface {
   }
 
   public static function canUpdate($project_name) {
-    return (bool) drupal_get_path('module', $project_name);
+    return (bool) get_path('module', $project_name);
   }
 
   /**
    * Return available database schema updates one a new version is installed.
    */
   public function getSchemaUpdates() {
-    require_once DRUPAL_ROOT . '/core/includes/install.inc';
-    require_once DRUPAL_ROOT . '/core/includes/update.inc';
+    require_once ROOT . '/core/includes/install.inc';
+    require_once ROOT . '/core/includes/update.inc';
 
     if (_update_get_project_type($project) != 'module') {
       return array();
     }
     module_load_include('install', $project);
 
-    if (!$updates = drupal_get_schema_versions($project)) {
+    if (!$updates = get_schema_versions($project)) {
       return array();
     }
     $updates_to_run = array();
@@ -90,14 +91,14 @@ class ModuleUpdater extends Updater implements DrupalUpdaterInterface {
 /**
  * Class for updating themes using FileTransfer classes via authorize.php.
  */
-class ThemeUpdater extends Updater implements DrupalUpdaterInterface {
+class ThemeUpdater extends Updater implements UpdaterInterface {
 
   /**
    * Return the directory where a theme should be installed.
    *
-   * If the theme is already installed, drupal_get_path() will return
+   * If the theme is already installed, get_path() will return
    * a valid path and we should install it there (although we need to use an
-   * absolute path, so we prepend DRUPAL_ROOT). If we're installing a new
+   * absolute path, so we prepend ROOT). If we're installing a new
    * theme, we always want it to go into sites/all/themes, since that's
    * where all the documentation recommends users install their themes, and
    * there's no way that can conflict on a multi-site installation, since
@@ -105,17 +106,17 @@ class ThemeUpdater extends Updater implements DrupalUpdaterInterface {
    * found on your system, and if there was a copy in sites/all, we'd see it.
    */
   public function getInstallDirectory() {
-    if ($relative_path = drupal_get_path('theme', $this->name)) {
+    if ($relative_path = get_path('theme', $this->name)) {
       $relative_path = dirname($relative_path);
     }
     else {
       $relative_path = 'sites/all/themes';
     }
-    return DRUPAL_ROOT . '/' . $relative_path;
+    return ROOT . '/' . $relative_path;
   }
 
   public function isInstalled() {
-    return (bool) drupal_get_path('theme', $this->name);
+    return (bool) get_path('theme', $this->name);
   }
 
   static function canUpdateDirectory($directory) {
@@ -127,7 +128,7 @@ class ThemeUpdater extends Updater implements DrupalUpdaterInterface {
   }
 
   public static function canUpdate($project_name) {
-    return (bool) drupal_get_path('theme', $project_name);
+    return (bool) get_path('theme', $project_name);
   }
 
   public function postInstall() {
diff --git a/core/modules/system/theme.api.php b/core/modules/system/theme.api.php
index 7fee81c..6df4be0 100644
--- a/core/modules/system/theme.api.php
+++ b/core/modules/system/theme.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @defgroup themeable Default theme implementations
diff --git a/core/modules/taxonomy/taxonomy-term.tpl.php b/core/modules/taxonomy/taxonomy-term.tpl.php
index b1ff20e..62c06b1 100644
--- a/core/modules/taxonomy/taxonomy-term.tpl.php
+++ b/core/modules/taxonomy/taxonomy-term.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/taxonomy/taxonomy.admin.inc b/core/modules/taxonomy/taxonomy.admin.inc
index bfb4c11..4dc026d 100644
--- a/core/modules/taxonomy/taxonomy.admin.inc
+++ b/core/modules/taxonomy/taxonomy.admin.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -54,7 +55,7 @@ function taxonomy_overview_vocabularies_submit($form, &$form_state) {
       taxonomy_vocabulary_save($form[$vid]['#vocabulary']);
     }
   }
-  drupal_set_message(t('The configuration options have been saved.'));
+  set_message(t('The configuration options have been saved.'));
 }
 
 /**
@@ -92,10 +93,10 @@ function theme_taxonomy_overview_vocabularies($variables) {
   $header = array(t('Vocabulary name'));
   if (isset($form['actions'])) {
     $header[] = t('Weight');
-    drupal_add_tabledrag('taxonomy', 'order', 'sibling', 'vocabulary-weight');
+    add_tabledrag('taxonomy', 'order', 'sibling', 'vocabulary-weight');
   }
   $header[] = array('data' => t('Operations'), 'colspan' => '3');
-  return theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No vocabularies available. <a href="@link">Add vocabulary</a>.', array('@link' => url('admin/structure/taxonomy/add'))), 'attributes' => array('id' => 'taxonomy'))) . drupal_render_children($form);
+  return theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No vocabularies available. <a href="@link">Add vocabulary</a>.', array('@link' => url('admin/structure/taxonomy/add'))), 'attributes' => array('id' => 'taxonomy'))) . render_children($form);
 }
 
 /**
@@ -220,13 +221,13 @@ function taxonomy_form_vocabulary_submit($form, &$form_state) {
 
   switch (taxonomy_vocabulary_save($vocabulary)) {
     case SAVED_NEW:
-      drupal_set_message(t('Created new vocabulary %name.', array('%name' => $vocabulary->name)));
+      set_message(t('Created new vocabulary %name.', array('%name' => $vocabulary->name)));
       watchdog('taxonomy', 'Created new vocabulary %name.', array('%name' => $vocabulary->name), WATCHDOG_NOTICE, l(t('edit'), 'admin/structure/taxonomy/' . $vocabulary->machine_name . '/edit'));
       $form_state['redirect'] = 'admin/structure/taxonomy/' . $vocabulary->machine_name;
       break;
 
     case SAVED_UPDATED:
-      drupal_set_message(t('Updated vocabulary %name.', array('%name' => $vocabulary->name)));
+      set_message(t('Updated vocabulary %name.', array('%name' => $vocabulary->name)));
       watchdog('taxonomy', 'Updated vocabulary %name.', array('%name' => $vocabulary->name), WATCHDOG_NOTICE, l(t('edit'), 'admin/structure/taxonomy/' . $vocabulary->machine_name . '/edit'));
       $form_state['redirect'] = 'admin/structure/taxonomy';
       break;
@@ -392,7 +393,7 @@ function taxonomy_overview_terms($form, &$form_state, $vocabulary) {
         '#default_value' => $term->weight,
       );
     }
-    $form[$key]['edit'] = array('#type' => 'link', '#title' => t('edit'), '#href' => 'taxonomy/term/' . $term->tid . '/edit', '#options' => array('query' => drupal_get_destination()));
+    $form[$key]['edit'] = array('#type' => 'link', '#title' => t('edit'), '#href' => 'taxonomy/term/' . $term->tid . '/edit', '#options' => array('query' => get_destination()));
   }
 
   $form['#total_entries'] = $total_entries;
@@ -446,7 +447,7 @@ function taxonomy_overview_terms_submit($form, &$form_state) {
   }
 
   // Sort term order based on weight.
-  uasort($form_state['values'], 'drupal_sort_weight');
+  uasort($form_state['values'], 'Drupal\sort_weight');
 
   $vocabulary = $form['#vocabulary'];
   // Update the current hierarchy type as we go.
@@ -533,7 +534,7 @@ function taxonomy_overview_terms_submit($form, &$form_state) {
     $vocabulary->hierarchy = $hierarchy;
     taxonomy_vocabulary_save($vocabulary);
   }
-  drupal_set_message(t('The configuration options have been saved.'));
+  set_message(t('The configuration options have been saved.'));
 }
 
 /**
@@ -556,13 +557,13 @@ function theme_taxonomy_overview_terms($variables) {
 
   // Add drag and drop if parent fields are present in the form.
   if ($form['#parent_fields']) {
-    drupal_add_tabledrag('taxonomy', 'match', 'parent', 'term-parent', 'term-parent', 'term-id', FALSE);
-    drupal_add_tabledrag('taxonomy', 'depth', 'group', 'term-depth', NULL, NULL, FALSE);
-    drupal_add_js(drupal_get_path('module', 'taxonomy') . '/taxonomy.js');
-    drupal_add_js(array('taxonomy' => array('backStep' => $back_step, 'forwardStep' => $forward_step)), 'setting');
-    drupal_add_css(drupal_get_path('module', 'taxonomy') . '/taxonomy.css');
+    add_tabledrag('taxonomy', 'match', 'parent', 'term-parent', 'term-parent', 'term-id', FALSE);
+    add_tabledrag('taxonomy', 'depth', 'group', 'term-depth', NULL, NULL, FALSE);
+    add_js(get_path('module', 'taxonomy') . '/taxonomy.js');
+    add_js(array('taxonomy' => array('backStep' => $back_step, 'forwardStep' => $forward_step)), 'setting');
+    add_css(get_path('module', 'taxonomy') . '/taxonomy.css');
   }
-  drupal_add_tabledrag('taxonomy', 'order', 'sibling', 'term-weight');
+  add_tabledrag('taxonomy', 'order', 'sibling', 'term-weight');
 
   $errors = form_get_errors() != FALSE ? form_get_errors() : array();
   $rows = array();
@@ -623,7 +624,7 @@ function theme_taxonomy_overview_terms($variables) {
 
   $header = array(t('Name'), t('Weight'), t('Operations'));
   $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'taxonomy')));
-  $output .= drupal_render_children($form);
+  $output .= render_children($form);
   $output .= theme('pager');
 
   return $output;
@@ -815,11 +816,11 @@ function taxonomy_form_term_submit($form, &$form_state) {
   $status = taxonomy_term_save($term);
   switch ($status) {
     case SAVED_NEW:
-      drupal_set_message(t('Created new term %term.', array('%term' => $term->name)));
+      set_message(t('Created new term %term.', array('%term' => $term->name)));
       watchdog('taxonomy', 'Created new term %term.', array('%term' => $term->name), WATCHDOG_NOTICE, l(t('edit'), 'taxonomy/term/' . $term->tid . '/edit'));
       break;
     case SAVED_UPDATED:
-      drupal_set_message(t('Updated term %term.', array('%term' => $term->name)));
+      set_message(t('Updated term %term.', array('%term' => $term->name)));
       watchdog('taxonomy', 'Updated term %term.', array('%term' => $term->name), WATCHDOG_NOTICE, l(t('edit'), 'taxonomy/term/' . $term->tid . '/edit'));
       // Clear the page and block caches to avoid stale data.
       cache_clear_all();
@@ -898,7 +899,7 @@ function taxonomy_term_confirm_delete($form, &$form_state, $tid) {
 function taxonomy_term_confirm_delete_submit($form, &$form_state) {
   taxonomy_term_delete($form_state['values']['tid']);
   taxonomy_check_vocabulary_hierarchy($form['#vocabulary'], $form_state['values']);
-  drupal_set_message(t('Deleted term %name.', array('%name' => $form_state['values']['name'])));
+  set_message(t('Deleted term %name.', array('%name' => $form_state['values']['name'])));
   watchdog('taxonomy', 'Deleted term %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
   $form_state['redirect'] = 'admin/structure/taxonomy';
   cache_clear_all();
@@ -938,7 +939,7 @@ function taxonomy_vocabulary_confirm_delete($form, &$form_state, $vid) {
  */
 function taxonomy_vocabulary_confirm_delete_submit($form, &$form_state) {
   $status = taxonomy_vocabulary_delete($form_state['values']['vid']);
-  drupal_set_message(t('Deleted vocabulary %name.', array('%name' => $form_state['values']['name'])));
+  set_message(t('Deleted vocabulary %name.', array('%name' => $form_state['values']['name'])));
   watchdog('taxonomy', 'Deleted vocabulary %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
   $form_state['redirect'] = 'admin/structure/taxonomy';
   cache_clear_all();
@@ -978,7 +979,7 @@ function taxonomy_vocabulary_confirm_reset_alphabetical_submit($form, &$form_sta
     ->fields(array('weight' => 0))
     ->condition('vid', $form_state['values']['vid'])
     ->execute();
-  drupal_set_message(t('Reset vocabulary %name to alphabetical order.', array('%name' => $form_state['values']['name'])));
+  set_message(t('Reset vocabulary %name to alphabetical order.', array('%name' => $form_state['values']['name'])));
   watchdog('taxonomy', 'Reset vocabulary %name to alphabetical order.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
   $form_state['redirect'] = 'admin/structure/taxonomy/' . $form_state['values']['machine_name'];
 }
diff --git a/core/modules/taxonomy/taxonomy.api.php b/core/modules/taxonomy/taxonomy.api.php
index 426306d..53eb91b 100644
--- a/core/modules/taxonomy/taxonomy.api.php
+++ b/core/modules/taxonomy/taxonomy.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/taxonomy/taxonomy.install b/core/modules/taxonomy/taxonomy.install
index 3e07259..c8dc515 100644
--- a/core/modules/taxonomy/taxonomy.install
+++ b/core/modules/taxonomy/taxonomy.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module
index 606abfc..6e59738 100644
--- a/core/modules/taxonomy/taxonomy.module
+++ b/core/modules/taxonomy/taxonomy.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -275,7 +277,7 @@ function taxonomy_menu() {
   $items['admin/structure/taxonomy'] = array(
     'title' => 'Taxonomy',
     'description' => 'Manage tagging, categorization, and classification of your content.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('taxonomy_overview_vocabularies'),
     'access arguments' => array('administer taxonomy'),
     'file' => 'taxonomy.admin.inc',
@@ -287,7 +289,7 @@ function taxonomy_menu() {
   );
   $items['admin/structure/taxonomy/add'] = array(
     'title' => 'Add vocabulary',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('taxonomy_form_vocabulary'),
     'access arguments' => array('administer taxonomy'),
     'type' => MENU_LOCAL_ACTION,
@@ -309,7 +311,7 @@ function taxonomy_menu() {
   );
   $items['taxonomy/term/%taxonomy_term/edit'] = array(
     'title' => 'Edit',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     // Pass a NULL argument to ensure that additional path components are not
     // passed to taxonomy_form_term() as the vocabulary machine name argument.
     'page arguments' => array('taxonomy_form_term', 2, NULL),
@@ -340,7 +342,7 @@ function taxonomy_menu() {
   $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name'] = array(
     'title callback' => 'taxonomy_admin_vocabulary_title_callback',
     'title arguments' => array(3),
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('taxonomy_overview_terms', 3),
     'access arguments' => array('administer taxonomy'),
     'file' => 'taxonomy.admin.inc',
@@ -352,7 +354,7 @@ function taxonomy_menu() {
   );
   $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/edit'] = array(
     'title' => 'Edit',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('taxonomy_form_vocabulary', 3),
     'access arguments' => array('administer taxonomy'),
     'type' => MENU_LOCAL_TASK,
@@ -362,7 +364,7 @@ function taxonomy_menu() {
 
   $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/add'] = array(
     'title' => 'Add term',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('taxonomy_form_term', array(), 3),
     'access arguments' => array('administer taxonomy'),
     'type' => MENU_LOCAL_ACTION,
@@ -438,7 +440,7 @@ function taxonomy_vocabulary_save($vocabulary) {
   module_invoke_all('entity_presave', $vocabulary, 'taxonomy_vocabulary');
 
   if (!empty($vocabulary->vid) && !empty($vocabulary->name)) {
-    $status = drupal_write_record('taxonomy_vocabulary', $vocabulary, 'vid');
+    $status = write_record('taxonomy_vocabulary', $vocabulary, 'vid');
     taxonomy_vocabulary_static_reset(array($vocabulary->vid));
     if ($vocabulary->old_machine_name != $vocabulary->machine_name) {
       field_attach_rename_bundle('taxonomy_term', $vocabulary->old_machine_name, $vocabulary->machine_name);
@@ -447,7 +449,7 @@ function taxonomy_vocabulary_save($vocabulary) {
     module_invoke_all('entity_update', $vocabulary, 'taxonomy_vocabulary');
   }
   elseif (empty($vocabulary->vid)) {
-    $status = drupal_write_record('taxonomy_vocabulary', $vocabulary);
+    $status = write_record('taxonomy_vocabulary', $vocabulary);
     taxonomy_vocabulary_static_reset();
     field_attach_create_bundle('taxonomy_term', $vocabulary->machine_name);
     module_invoke_all('taxonomy_vocabulary_insert', $vocabulary);
@@ -627,7 +629,7 @@ function taxonomy_term_save($term) {
 
   if (empty($term->tid)) {
     $op = 'insert';
-    $status = drupal_write_record('taxonomy_term_data', $term);
+    $status = write_record('taxonomy_term_data', $term);
     field_attach_insert('taxonomy_term', $term);
     if (!isset($term->parent)) {
       $term->parent = array(0);
@@ -635,7 +637,7 @@ function taxonomy_term_save($term) {
   }
   else {
     $op = 'update';
-    $status = drupal_write_record('taxonomy_term_data', $term, 'tid');
+    $status = write_record('taxonomy_term_data', $term, 'tid');
     field_attach_update('taxonomy_term', $term);
     if (isset($term->parent)) {
       db_delete('taxonomy_term_hierarchy')
@@ -784,11 +786,11 @@ function taxonomy_term_view($term, $view_mode = 'full', $langcode = NULL) {
     );
   }
 
-  $build['#attached']['css'][] = drupal_get_path('module', 'taxonomy') . '/taxonomy.css';
+  $build['#attached']['css'][] = get_path('module', 'taxonomy') . '/taxonomy.css';
 
   // Allow modules to modify the structured term.
   $type = 'taxonomy_term';
-  drupal_alter(array('taxonomy_term_view', 'entity_view'), $build, $type);
+  alter(array('taxonomy_term_view', 'entity_view'), $build, $type);
 
   return $build;
 }
@@ -844,13 +846,13 @@ function taxonomy_term_is_page($term) {
  * Clear all static cache variables for terms.
  */
 function taxonomy_terms_static_reset() {
-  drupal_static_reset('taxonomy_term_count_nodes');
-  drupal_static_reset('taxonomy_get_tree');
-  drupal_static_reset('taxonomy_get_tree:parents');
-  drupal_static_reset('taxonomy_get_tree:terms');
-  drupal_static_reset('taxonomy_term_load_parents');
-  drupal_static_reset('taxonomy_term_load_parents_all');
-  drupal_static_reset('taxonomy_term_load_children');
+  drupal_static_reset('Drupal\taxonomy_term_count_nodes');
+  drupal_static_reset('Drupal\taxonomy_get_tree');
+  drupal_static_reset('Drupal\taxonomy_get_tree:parents');
+  drupal_static_reset('Drupal\taxonomy_get_tree:terms');
+  drupal_static_reset('Drupal\taxonomy_term_load_parents');
+  drupal_static_reset('Drupal\taxonomy_term_load_parents_all');
+  drupal_static_reset('Drupal\taxonomy_term_load_children');
   entity_get_controller('taxonomy_term')->resetCache();
 }
 
@@ -861,7 +863,7 @@ function taxonomy_terms_static_reset() {
  * An array of ids to reset in entity controller cache.
  */
 function taxonomy_vocabulary_static_reset($ids = NULL) {
-  drupal_static_reset('taxonomy_vocabulary_get_names');
+  drupal_static_reset('Drupal\taxonomy_vocabulary_get_names');
   entity_get_controller('taxonomy_vocabulary')->resetCache($ids);
 }
 
@@ -1117,10 +1119,10 @@ function taxonomy_term_load_multiple_by_name($name, $vocabulary = NULL) {
 /**
  * Controller class for taxonomy terms.
  *
- * This extends the DrupalDefaultEntityController class. Only alteration is
+ * This extends the DefaultEntityController class. Only alteration is
  * that we match the condition on term name case-independently.
  */
-class TaxonomyTermController extends DrupalDefaultEntityController {
+class TaxonomyTermController extends DefaultEntityController {
 
   protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
     $query = parent::buildQuery($ids, $conditions, $revision_id);
@@ -1159,10 +1161,10 @@ class TaxonomyTermController extends DrupalDefaultEntityController {
 /**
  * Controller class for taxonomy vocabularies.
  *
- * This extends the DrupalDefaultEntityController class, adding required
+ * This extends the DefaultEntityController class, adding required
  * special handling for taxonomy vocabulary objects.
  */
-class TaxonomyVocabularyController extends DrupalDefaultEntityController {
+class TaxonomyVocabularyController extends DefaultEntityController {
 
   protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
     $query = parent::buildQuery($ids, $conditions, $revision_id);
@@ -1284,7 +1286,7 @@ function _taxonomy_get_tid_from_term($term) {
 /**
  * Implodes a list of tags of a certain vocabulary into a string.
  *
- * @see drupal_explode_tags()
+ * @see explode_tags()
  */
 function taxonomy_implode_tags($tags, $vid = NULL) {
   $typed_tags = array();
@@ -1367,7 +1369,7 @@ function taxonomy_field_widget_info_alter(&$info) {
  * Implements hook_options_list().
  */
 function taxonomy_options_list($field, $instance) {
-  $function = !empty($field['settings']['options_list_callback']) ? $field['settings']['options_list_callback'] : 'taxonomy_allowed_values';
+  $function = 'Drupal\\' . (!empty($field['settings']['options_list_callback']) ? $field['settings']['options_list_callback'] : 'taxonomy_allowed_values');
   return $function($field);
 }
 
@@ -1624,7 +1626,7 @@ function taxonomy_autocomplete_validate($element, &$form_state) {
     }
 
     // Translate term names into actual terms.
-    $typed_terms = drupal_explode_tags($tags);
+    $typed_terms = explode_tags($tags);
     foreach ($typed_terms as $typed_term) {
       // See if the term exists in the chosen vocabulary and return the tid;
       // otherwise, create a new 'autocreate' term for insert/update.
diff --git a/core/modules/taxonomy/taxonomy.pages.inc b/core/modules/taxonomy/taxonomy.pages.inc
index aeb12d7..7cfa07e 100644
--- a/core/modules/taxonomy/taxonomy.pages.inc
+++ b/core/modules/taxonomy/taxonomy.pages.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -15,7 +16,7 @@
  */
 function taxonomy_term_page($term) {
   // Assign the term name as the page title.
-  drupal_set_title($term->name);
+  set_title($term->name);
 
   // Build breadcrumb based on the hierarchy of the term.
   $current = (object) array(
@@ -30,8 +31,8 @@ function taxonomy_term_page($term) {
   }
   $breadcrumb[] = l(t('Home'), NULL);
   $breadcrumb = array_reverse($breadcrumb);
-  drupal_set_breadcrumb($breadcrumb);
-  drupal_add_feed('taxonomy/term/' . $term->tid . '/feed', 'RSS - ' . $term->name);
+  set_breadcrumb($breadcrumb);
+  add_feed('taxonomy/term/' . $term->tid . '/feed', 'RSS - ' . $term->name);
 
   $build = array();
 
@@ -111,7 +112,7 @@ function taxonomy_autocomplete($field_name, $tags_typed = '') {
   $field = field_info_field($field_name);
 
   // The user enters a comma-separated list of tags. We only autocomplete the last tag.
-  $tags_typed = drupal_explode_tags($tags_typed);
+  $tags_typed = explode_tags($tags_typed);
   $tag_last = drupal_strtolower(array_pop($tags_typed));
 
   $matches = array();
@@ -141,7 +142,7 @@ function taxonomy_autocomplete($field_name, $tags_typed = '') {
       ->execute()
       ->fetchAllKeyed();
 
-    $prefix = count($tags_typed) ? drupal_implode_tags($tags_typed) . ', ' : '';
+    $prefix = count($tags_typed) ? implode_tags($tags_typed) . ', ' : '';
 
     $term_matches = array();
     foreach ($tags_return as $tid => $name) {
@@ -154,5 +155,5 @@ function taxonomy_autocomplete($field_name, $tags_typed = '') {
     }
   }
 
-  drupal_json_output($term_matches);
+  json_output($term_matches);
 }
diff --git a/core/modules/taxonomy/taxonomy.test b/core/modules/taxonomy/taxonomy.test
index aa3c209..6acefef 100644
--- a/core/modules/taxonomy/taxonomy.test
+++ b/core/modules/taxonomy/taxonomy.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, stdClass;
 
 /**
  * @file
@@ -8,7 +10,7 @@
 /**
 * Class with common helper methods.
 */
-class TaxonomyWebTestCase extends DrupalWebTestCase {
+class TaxonomyWebTestCase extends WebTestCase {
 
   /**
    * Returns a new vocabulary with random properties.
@@ -375,9 +377,9 @@ class TaxonomyVocabularyUnitTest extends TaxonomyWebTestCase {
     field_create_instance($this->instance);
 
     module_disable(array('taxonomy'));
-    drupal_flush_all_caches();
-    require_once DRUPAL_ROOT . '/core/includes/install.inc';
-    drupal_uninstall_modules(array('taxonomy'));
+    flush_all_caches();
+    require_once ROOT . '/core/includes/install.inc';
+    uninstall_modules(array('taxonomy'));
     module_enable(array('taxonomy'));
 
     // Now create a vocabulary with the same name. All field instances
@@ -650,7 +652,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
     $edit["body[$langcode][0][value]"] = $this->randomName();
     // Insert the terms in a comma separated list. Vocabulary 1 is a
     // free-tagging field created by the default profile.
-    $edit[$instance['field_name'] . "[$langcode]"] = drupal_implode_tags($terms);
+    $edit[$instance['field_name'] . "[$langcode]"] = implode_tags($terms);
 
     // Preview and verify the terms appear but are not created.
     $this->drupalPost('node/add/page', $edit, t('Preview'));
@@ -786,9 +788,9 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
 
     // Fetch the created terms in the default alphabetical order, i.e. term1
     // precedes term2 alphabetically, and term2 precedes term3.
-    drupal_static_reset('taxonomy_get_tree');
-    drupal_static_reset('taxonomy_get_treeparent');
-    drupal_static_reset('taxonomy_get_treeterms');
+    drupal_static_reset('Drupal\taxonomy_get_tree');
+    drupal_static_reset('Drupal\taxonomy_get_treeparent');
+    drupal_static_reset('Drupal\taxonomy_get_treeterms');
     list($term1, $term2, $term3) = taxonomy_get_tree($this->vocabulary->vid);
 
     $this->drupalGet('admin/structure/taxonomy/' . $this->vocabulary->machine_name);
@@ -813,9 +815,9 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
     );
     $this->drupalPost(NULL, $edit, t('Save'));
 
-    drupal_static_reset('taxonomy_get_tree');
-    drupal_static_reset('taxonomy_get_treeparent');
-    drupal_static_reset('taxonomy_get_treeterms');
+    drupal_static_reset('Drupal\taxonomy_get_tree');
+    drupal_static_reset('Drupal\taxonomy_get_treeparent');
+    drupal_static_reset('Drupal\taxonomy_get_treeterms');
     $terms = taxonomy_get_tree($this->vocabulary->vid);
     $this->assertEqual($terms[0]->tid, $term2->tid, t('Term 2 was moved above term 1.'));
     $this->assertEqual($terms[1]->parents, array($term2->tid), t('Term 3 was made a child of term 2.'));
@@ -825,9 +827,9 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
     // Submit confirmation form.
     $this->drupalPost(NULL, array(), t('Reset to alphabetical'));
 
-    drupal_static_reset('taxonomy_get_tree');
-    drupal_static_reset('taxonomy_get_treeparent');
-    drupal_static_reset('taxonomy_get_treeterms');
+    drupal_static_reset('Drupal\taxonomy_get_tree');
+    drupal_static_reset('Drupal\taxonomy_get_treeparent');
+    drupal_static_reset('Drupal\taxonomy_get_treeterms');
     $terms = taxonomy_get_tree($this->vocabulary->vid);
     $this->assertEqual($terms[0]->tid, $term1->tid, t('Term 1 was moved to back above term 2.'));
     $this->assertEqual($terms[1]->tid, $term2->tid, t('Term 2 was moved to back below term 1.'));
diff --git a/core/modules/taxonomy/taxonomy.tokens.inc b/core/modules/taxonomy/taxonomy.tokens.inc
index 24d7bc8..331b926 100644
--- a/core/modules/taxonomy/taxonomy.tokens.inc
+++ b/core/modules/taxonomy/taxonomy.tokens.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module
index 254a419..eb455f4 100644
--- a/core/modules/toolbar/toolbar.module
+++ b/core/modules/toolbar/toolbar.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -40,7 +41,7 @@ function toolbar_theme($existing, $type, $theme, $path) {
   $items['toolbar'] = array(
     'render element' => 'toolbar',
     'template' => 'toolbar',
-    'path' => drupal_get_path('module', 'toolbar'),
+    'path' => get_path('module', 'toolbar'),
   );
   $items['toolbar_toggle'] = array(
     'variables' => array(
@@ -76,7 +77,7 @@ function toolbar_toggle_page() {
   // Toggle the value in the cookie.
   setcookie('Drupal.toolbar.collapsed', !_toolbar_is_collapsed(), NULL, $base_path);
   // Redirect the user from where he used the toggle element.
-  drupal_goto();
+  redirect();
 }
 
 /**
@@ -100,7 +101,7 @@ function theme_toolbar_toggle($variables) {
     $toggle_text = t('Hide shortcuts');
     $variables['attributes']['class'][] = 'toggle-active';
   }
-  return l($toggle_text, 'toolbar/toggle', array('query' => drupal_get_destination(), 'attributes' => array('title' => $toggle_text) + $variables['attributes']));
+  return l($toggle_text, 'toolbar/toggle', array('query' => get_destination(), 'attributes' => array('title' => $toggle_text) + $variables['attributes']));
 }
 
 /**
@@ -190,7 +191,7 @@ function toolbar_system_info_alter(&$info, $file, $type) {
 function toolbar_view() {
   global $user;
 
-  $module_path = drupal_get_path('module', 'toolbar');
+  $module_path = get_path('module', 'toolbar');
   $build = array(
     '#theme' => 'toolbar',
     '#attached'=> array(
diff --git a/core/modules/toolbar/toolbar.tpl.php b/core/modules/toolbar/toolbar.tpl.php
index 342fa60..c14ef39 100644
--- a/core/modules/toolbar/toolbar.tpl.php
+++ b/core/modules/toolbar/toolbar.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/tracker/tracker.install b/core/modules/tracker/tracker.install
index cfe8dc7..c8ea2d0 100644
--- a/core/modules/tracker/tracker.install
+++ b/core/modules/tracker/tracker.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Implements hook_uninstall().
diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module
index 89907b5..9f29ba5 100644
--- a/core/modules/tracker/tracker.module
+++ b/core/modules/tracker/tracker.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/tracker/tracker.pages.inc b/core/modules/tracker/tracker.pages.inc
index e1424c3..fbdaab0 100644
--- a/core/modules/tracker/tracker.pages.inc
+++ b/core/modules/tracker/tracker.pages.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -18,7 +19,7 @@ function tracker_page($account = NULL, $set_title = FALSE) {
       // When viewed from user/%user/track, display the name of the user
       // as page title -- the tab title remains Track so this needs to be done
       // here and not in the menu definition.
-      drupal_set_title(user_format_name($account));
+      set_title(user_format_name($account));
     }
   }
   else {
@@ -67,7 +68,7 @@ function tracker_page($account = NULL, $set_title = FALSE) {
       );
 
       // Adds extra RDFa markup to the $row array if the RDF module is enabled.
-      if (function_exists('rdf_mapping_load')) {
+      if (function_exists('Drupal\rdf_mapping_load')) {
         // Each node is not loaded for performance reasons, as a result we need
         // to retrieve the RDF mapping for each node type.
         $mapping = rdf_mapping_load('node', $node->type);
diff --git a/core/modules/tracker/tracker.test b/core/modules/tracker/tracker.test
index a559f1b..f2ccd2e 100644
--- a/core/modules/tracker/tracker.test
+++ b/core/modules/tracker/tracker.test
@@ -1,11 +1,12 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
  * Tests for tracker.module.
  */
 
-class TrackerTest extends DrupalWebTestCase {
+class TrackerTest extends WebTestCase {
   protected $user;
   protected $other_user;
 
diff --git a/core/modules/translation/tests/translation_test.module b/core/modules/translation/tests/translation_test.module
index e3bb4b5..4f99f36 100644
--- a/core/modules/translation/tests/translation_test.module
+++ b/core/modules/translation/tests/translation_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -9,5 +10,5 @@
  * Implements hook_node_insert().
  */
 function translation_test_node_insert($node) {
-  drupal_write_record('node', $node, 'nid');
+  write_record('node', $node, 'nid');
 }
diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module
index e121f04..eabb52b 100644
--- a/core/modules/translation/translation.module
+++ b/core/modules/translation/translation.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -296,7 +297,7 @@ function translation_node_prepare($node) {
     if (!empty($source_node->tnid)) {
       $translations = translation_node_get_translations($source_node->tnid);
       if (isset($translations[$langcode])) {
-        drupal_set_message(t('A translation of %title in %language already exists, a new %type will be created instead of a translation.', array('%title' => $source_node->title, '%language' => $language_list[$langcode]->name, '%type' => $node->type)), 'error');
+        set_message(t('A translation of %title in %language already exists, a new %type will be created instead of a translation.', array('%title' => $source_node->title, '%language' => $language_list[$langcode]->name, '%type' => $node->type)), 'error');
         return;
       }
     }
diff --git a/core/modules/translation/translation.pages.inc b/core/modules/translation/translation.pages.inc
index 8c09850..9368559 100644
--- a/core/modules/translation/translation.pages.inc
+++ b/core/modules/translation/translation.pages.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -12,7 +13,7 @@
  *   Node object.
  */
 function translation_node_overview($node) {
-  include_once DRUPAL_ROOT . '/core/includes/language.inc';
+  include_once ROOT . '/core/includes/language.inc';
 
   if ($node->tnid) {
     // Already part of a set, grab that set.
@@ -65,7 +66,7 @@ function translation_node_overview($node) {
     $rows[] = array($language_name, $title, $status, implode(" | ", $options));
   }
 
-  drupal_set_title(t('Translations of %title', array('%title' => $node->title)), PASS_THROUGH);
+  set_title(t('Translations of %title', array('%title' => $node->title)), PASS_THROUGH);
 
   $build['translation_node_overview'] = array(
     '#theme' => 'table',
diff --git a/core/modules/translation/translation.test b/core/modules/translation/translation.test
index dd00734..bc2fca0 100644
--- a/core/modules/translation/translation.test
+++ b/core/modules/translation/translation.test
@@ -1,11 +1,12 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
  * Tests for translation.module
  */
 
-class TranslationTestCase extends DrupalWebTestCase {
+class TranslationTestCase extends WebTestCase {
   protected $book;
 
   public static function getInfo() {
@@ -255,9 +256,9 @@ class TranslationTestCase extends DrupalWebTestCase {
    * Reset static caches to make the test code match the client site behavior.
    */
   function resetCaches() {
-    drupal_static_reset('language_list');
-    drupal_static_reset('locale_url_outbound_alter');
-    drupal_static_reset('locale_language_url_rewrite_url');
+    drupal_static_reset('Drupal\language_list');
+    drupal_static_reset('Drupal\locale_url_outbound_alter');
+    drupal_static_reset('Drupal\locale_language_url_rewrite_url');
   }
 
   /**
@@ -285,7 +286,7 @@ class TranslationTestCase extends DrupalWebTestCase {
       $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
 
       // Make sure we are not using a stale list.
-      drupal_static_reset('language_list');
+      drupal_static_reset('Drupal\language_list');
       $languages = language_list();
       $this->assertTrue(array_key_exists($language_code, $languages), t('Language was installed successfully.'));
 
diff --git a/core/modules/update/tests/aaa_update_test.module b/core/modules/update/tests/aaa_update_test.module
index 4d67b8e..6fb054f 100644
--- a/core/modules/update/tests/aaa_update_test.module
+++ b/core/modules/update/tests/aaa_update_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/update/tests/bbb_update_test.module b/core/modules/update/tests/bbb_update_test.module
index 4d67b8e..6fb054f 100644
--- a/core/modules/update/tests/bbb_update_test.module
+++ b/core/modules/update/tests/bbb_update_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/update/tests/ccc_update_test.module b/core/modules/update/tests/ccc_update_test.module
index 4d67b8e..6fb054f 100644
--- a/core/modules/update/tests/ccc_update_test.module
+++ b/core/modules/update/tests/ccc_update_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/update/tests/update_test.module b/core/modules/update/tests/update_test.module
index e7ee43e..22f5284 100644
--- a/core/modules/update/tests/update_test.module
+++ b/core/modules/update/tests/update_test.module
@@ -1,11 +1,12 @@
 <?php
+namespace Drupal;
 
 /**
  * Implements hook_system_theme_info().
  */
 function update_test_system_theme_info() {
-  $themes['update_test_basetheme'] = drupal_get_path('module', 'update_test') . '/themes/update_test_basetheme/update_test_basetheme.info';
-  $themes['update_test_subtheme'] = drupal_get_path('module', 'update_test') . '/themes/update_test_subtheme/update_test_subtheme.info';
+  $themes['update_test_basetheme'] = get_path('module', 'update_test') . '/themes/update_test_basetheme/update_test_basetheme.info';
+  $themes['update_test_subtheme'] = get_path('module', 'update_test') . '/themes/update_test_subtheme/update_test_subtheme.info';
   return $themes;
 }
 
@@ -110,7 +111,7 @@ function update_test_mock_page($project_name) {
     $availability_scenario = '#broken#';
   }
 
-  $path = drupal_get_path('module', 'update_test');
+  $path = get_path('module', 'update_test');
   readfile("$path/$project_name.$availability_scenario.xml");
 }
 
@@ -168,6 +169,6 @@ class UpdateTestFileTransfer {
  * Return an Error 503 (Service unavailable) page.
  */
 function update_callback_service_unavailable() {
-  drupal_add_http_header('Status', '503 Service unavailable');
+  add_http_header('Status', '503 Service unavailable');
   print "503 Service Temporarily Unavailable";
 }
diff --git a/core/modules/update/update.api.php b/core/modules/update/update.api.php
index 83b93b2..772a588 100644
--- a/core/modules/update/update.api.php
+++ b/core/modules/update/update.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/update/update.authorize.inc b/core/modules/update/update.authorize.inc
index 35dde0e..397afe3 100644
--- a/core/modules/update/update.authorize.inc
+++ b/core/modules/update/update.authorize.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -41,7 +43,7 @@ function update_authorize_run_update($filetransfer, $projects) {
     'init_message' => t('Preparing to update your site'),
     'operations' => $operations,
     'finished' => 'update_authorize_update_batch_finished',
-    'file' => drupal_get_path('module', 'update') . '/update.authorize.inc',
+    'file' => get_path('module', 'update') . '/update.authorize.inc',
   );
 
   batch_set($batch);
@@ -81,7 +83,7 @@ function update_authorize_run_install($filetransfer, $project, $updater_name, $l
     'operations' => $operations,
     // @todo Use a different finished callback for different messages?
     'finished' => 'update_authorize_install_batch_finished',
-    'file' => drupal_get_path('module', 'update') . '/update.authorize.inc',
+    'file' => get_path('module', 'update') . '/update.authorize.inc',
   );
   batch_set($batch);
 
diff --git a/core/modules/update/update.compare.inc b/core/modules/update/update.compare.inc
index 2ccd97c..e92c7c9 100644
--- a/core/modules/update/update.compare.inc
+++ b/core/modules/update/update.compare.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -44,7 +45,7 @@ function update_get_projects() {
         _update_process_info_list($projects, $theme_data, 'theme', FALSE);
       }
       // Allow other modules to alter projects before fetching and comparing.
-      drupal_alter('update_projects', $projects);
+      alter('update_projects', $projects);
       // Cache the site's project data for at most 1 hour.
       _update_cache_set('update_project_projects', $projects, REQUEST_TIME + 3600);
     }
@@ -319,7 +320,7 @@ function update_calculate_project_data($available) {
   // Give other modules a chance to alter the status (for example, to allow a
   // contrib module to provide fine-grained settings to ignore specific
   // projects or releases).
-  drupal_alter('update_status', $projects);
+  alter('update_status', $projects);
 
   // Cache the site's update status for at most 1 hour.
   _update_cache_set('update_project_data', $projects, REQUEST_TIME + 3600);
@@ -767,7 +768,7 @@ function update_project_cache($cid) {
  * Filter the project .info data to only save attributes we need.
  *
  * @param array $info
- *   Array of .info file data as returned by drupal_parse_info_file().
+ *   Array of .info file data as returned by parse_info_file().
  *
  * @return
  *   Array of .info file data we need for the Update manager.
@@ -785,5 +786,5 @@ function update_filter_project_info($info) {
     'project status url',
     'version',
   );
-  return array_intersect_key($info, drupal_map_assoc($whitelist));
+  return array_intersect_key($info, map_assoc($whitelist));
 }
diff --git a/core/modules/update/update.fetch.inc b/core/modules/update/update.fetch.inc
index 7ac0dbe..a9be421 100644
--- a/core/modules/update/update.fetch.inc
+++ b/core/modules/update/update.fetch.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, SimpleXMLElement;
 
 /**
  * @file
@@ -18,7 +20,7 @@ function update_manual_status() {
     'title' => t('Checking available update data'),
     'progress_message' => t('Trying to check available update data ...'),
     'error_message' => t('Error checking available update data.'),
-    'file' => drupal_get_path('module', 'update') . '/update.fetch.inc',
+    'file' => get_path('module', 'update') . '/update.fetch.inc',
   );
   batch_set($batch);
   batch_process('admin/reports/updates');
@@ -28,7 +30,7 @@ function update_manual_status() {
  * Process a step in the batch for fetching available update data.
  */
 function update_fetch_data_batch(&$context) {
-  $queue = DrupalQueue::get('update_fetch_tasks');
+  $queue = Queue::get('update_fetch_tasks');
   if (empty($context['sandbox']['max'])) {
     $context['finished'] = 0;
     $context['sandbox']['max'] = $queue->numberOfItems();
@@ -83,15 +85,15 @@ function update_fetch_data_finished($success, $results) {
   if ($success) {
     if (!empty($results)) {
       if (!empty($results['updated'])) {
-        drupal_set_message(format_plural($results['updated'], 'Checked available update data for one project.', 'Checked available update data for @count projects.'));
+        set_message(format_plural($results['updated'], 'Checked available update data for one project.', 'Checked available update data for @count projects.'));
       }
       if (!empty($results['failures'])) {
-        drupal_set_message(format_plural($results['failures'], 'Failed to get available update data for one project.', 'Failed to get available update data for @count projects.'), 'error');
+        set_message(format_plural($results['failures'], 'Failed to get available update data for one project.', 'Failed to get available update data for @count projects.'), 'error');
       }
     }
   }
   else {
-    drupal_set_message(t('An error occurred trying to get available update data.'), 'error');
+    set_message(t('An error occurred trying to get available update data.'), 'error');
   }
 }
 
@@ -99,7 +101,7 @@ function update_fetch_data_finished($success, $results) {
  * Attempt to drain the queue of tasks for release history data to fetch.
  */
 function _update_fetch_data() {
-  $queue = DrupalQueue::get('update_fetch_tasks');
+  $queue = Queue::get('update_fetch_tasks');
   $end = time() + variable_get('update_max_fetch_time', UPDATE_MAX_FETCH_TIME);
   while (time() < $end && ($item = $queue->claimItem())) {
     _update_process_fetch_task($item->data);
@@ -136,13 +138,13 @@ function _update_process_fetch_task($project) {
 
   $success = FALSE;
   $available = array();
-  $site_key = drupal_hmac_base64($base_url, drupal_get_private_key());
+  $site_key = hmac_base64($base_url, get_private_key());
   $url = _update_build_fetch_url($project, $site_key);
   $fetch_url_base = _update_get_fetch_url_base($project);
   $project_name = $project['name'];
 
   if (empty($fail[$fetch_url_base]) || $fail[$fetch_url_base] < $max_fetch_attempts) {
-    $xml = drupal_http_request($url);
+    $xml = http_request($url);
     if (!isset($xml->error) && isset($xml->data)) {
       $data = $xml->data;
     }
@@ -235,7 +237,7 @@ function _update_create_fetch_task($project) {
   }
   $cid = 'fetch_task::' . $project['name'];
   if (empty($fetch_tasks[$cid])) {
-    $queue = DrupalQueue::get('update_fetch_tasks');
+    $queue = Queue::get('update_fetch_tasks');
     $queue->createItem($project);
     db_insert('cache_update')
       ->fields(array(
@@ -266,7 +268,7 @@ function _update_create_fetch_task($project) {
 function _update_build_fetch_url($project, $site_key = '') {
   $name = $project['name'];
   $url = _update_get_fetch_url_base($project);
-  $url .= '/' . $name . '/' . DRUPAL_CORE_COMPATIBILITY;
+  $url .= '/' . $name . '/' . CORE_COMPATIBILITY;
   // Only append a site_key and the version information if we have a site_key
   // in the first place, and if this is not a disabled module or theme. We do
   // not want to record usage statistics for disabled code.
@@ -330,7 +332,7 @@ function _update_cron_notify() {
         else {
           $target_language = $default_language;
         }
-        drupal_mail('update', 'status_notify', $target, $target_language, $params);
+        mail('update', 'status_notify', $target, $target_language, $params);
       }
     }
   }
diff --git a/core/modules/update/update.install b/core/modules/update/update.install
index f0d5499..cc6e79c 100644
--- a/core/modules/update/update.install
+++ b/core/modules/update/update.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -41,7 +42,7 @@ function update_requirements($phase) {
         // status constants are numbered in the right order of precedence, so
         // we just need to make sure the projects are sorted in ascending
         // order of status, and we can look at the first project we find.
-        uasort($data, '_update_project_status_sort');
+        uasort($data, 'Drupal\_update_project_status_sort');
         $first_project = reset($data);
         $requirements['update_contrib'] = _update_requirement_check($first_project, 'contrib');
       }
@@ -61,7 +62,7 @@ function update_requirements($phase) {
  * Implements hook_schema().
  */
 function update_schema() {
-  $schema['cache_update'] = drupal_get_schema_unprocessed('system', 'cache');
+  $schema['cache_update'] = get_schema_unprocessed('system', 'cache');
   $schema['cache_update']['description'] = 'Cache table for the Update module to store information about available releases, fetched from central server.';
   return $schema;
 }
@@ -70,7 +71,7 @@ function update_schema() {
  * Implements hook_install().
  */
 function update_install() {
-  $queue = DrupalQueue::get('update_fetch_tasks', TRUE);
+  $queue = Queue::get('update_fetch_tasks', TRUE);
   $queue->createQueue();
 }
 
@@ -91,7 +92,7 @@ function update_uninstall() {
   foreach ($variables as $variable) {
     variable_del($variable);
   }
-  $queue = DrupalQueue::get('update_fetch_tasks');
+  $queue = Queue::get('update_fetch_tasks');
   $queue->deleteQueue();
 }
 
diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc
index d9fd86f..252fe4f 100644
--- a/core/modules/update/update.manager.inc
+++ b/core/modules/update/update.manager.inc
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -72,7 +74,7 @@ function update_manager_update_form($form, $form_state = array(), $context) {
     return $form;
   }
 
-  $form['#attached']['css'][] = drupal_get_path('module', 'update') . '/update.css';
+  $form['#attached']['css'][] = get_path('module', 'update') . '/update.css';
 
   // This will be a nested array. The first key is the kind of project, which
   // can be either 'enabled', 'disabled', 'manual' (projects which require
@@ -275,7 +277,7 @@ function theme_update_manager_update_form($variables) {
   $form = $variables['form'];
   $last = variable_get('update_last_check', 0);
   $output = theme('update_last_check', array('last' => $last));
-  $output .= drupal_render_children($form);
+  $output .= render_children($form);
   return $output;
 }
 
@@ -323,7 +325,7 @@ function update_manager_update_form_submit($form, &$form_state) {
     'init_message' => t('Preparing to download selected updates'),
     'operations' => $operations,
     'finished' => 'update_manager_download_batch_finished',
-    'file' => drupal_get_path('module', 'update') . '/update.manager.inc',
+    'file' => get_path('module', 'update') . '/update.manager.inc',
   );
   batch_set($batch);
 }
@@ -337,17 +339,17 @@ function update_manager_download_batch_finished($success, $results) {
       'title' => t('Downloading updates failed:'),
       'items' => $results['errors'],
     );
-    drupal_set_message(theme('item_list', $error_list), 'error');
+    set_message(theme('item_list', $error_list), 'error');
   }
   elseif ($success) {
-    drupal_set_message(t('Updates downloaded successfully.'));
+    set_message(t('Updates downloaded successfully.'));
     $_SESSION['update_manager_update_projects'] = $results['projects'];
-    drupal_goto('admin/update/ready');
+    redirect('admin/update/ready');
   }
   else {
     // Ideally we're catching all Exceptions, so they should never see this,
     // but just in case, we have to tell them something.
-    drupal_set_message(t('Fatal error trying to download.'), 'error');
+    set_message(t('Fatal error trying to download.'), 'error');
   }
 }
 
@@ -410,7 +412,7 @@ function update_manager_update_ready_form_submit($form, &$form_state) {
 
   if (!empty($_SESSION['update_manager_update_projects'])) {
     // Make sure the Updater registry is loaded.
-    drupal_get_updaters();
+    get_updaters();
 
     $updates = array();
     $directory = _update_manager_extract_directory();
@@ -436,14 +438,14 @@ function update_manager_update_ready_form_submit($form, &$form_state) {
     // update_authorize_run_update() directly.
     if (fileowner($project_real_location) == fileowner(conf_path())) {
       module_load_include('inc', 'update', 'update.authorize');
-      $filetransfer = new FileTransferLocal(DRUPAL_ROOT);
+      $filetransfer = new FileTransferLocal(ROOT);
       update_authorize_run_update($filetransfer, $updates);
     }
     // Otherwise, go through the regular workflow to prompt for FTP/SSH
     // credentials and invoke update_authorize_run_update() indirectly with
     // whatever FileTransfer object authorize.php creates for us.
     else {
-      system_authorized_init('update_authorize_run_update', drupal_get_path('module', 'update') . '/update.authorize.inc', array($updates), t('Update manager'));
+      system_authorized_init('update_authorize_run_update', get_path('module', 'update') . '/update.authorize.inc', array($updates), t('Update manager'));
       $form_state['redirect'] = system_authorized_get_url();
     }
   }
@@ -547,7 +549,7 @@ function _update_manager_check_backends(&$form, $operation) {
     '#suffix' => '</p>',
   );
 
-  $available_backends = drupal_get_filetransfer_info();
+  $available_backends = get_filetransfer_info();
   if (empty($available_backends)) {
     if ($operation == 'update') {
       $form['available_backends']['#markup'] = t('Your server does not support updating modules and themes from this interface. Instead, update modules and themes by uploading the new versions directly to the server, as described in the <a href="@handbook_url">handbook</a>.', array('@handbook_url' => 'http://drupal.org/getting-started/install-contrib'));
@@ -662,14 +664,14 @@ function update_manager_install_form_submit($form, &$form_state) {
     // form element and have all of them appear!
     if (!empty($archive_errors)) {
       foreach ($archive_errors as $error) {
-        drupal_set_message($error, 'error');
+        set_message($error, 'error');
       }
     }
     return;
   }
 
   // Make sure the Updater registry is loaded.
-  drupal_get_updaters();
+  get_updaters();
 
   $project_location = $directory . '/' . $project;
   try {
@@ -711,14 +713,14 @@ function update_manager_install_form_submit($form, &$form_state) {
   // update_authorize_run_install() directly.
   if (fileowner($project_real_location) == fileowner(conf_path())) {
     module_load_include('inc', 'update', 'update.authorize');
-    $filetransfer = new FileTransferLocal(DRUPAL_ROOT);
-    call_user_func_array('update_authorize_run_install', array_merge(array($filetransfer), $arguments));
+    $filetransfer = new FileTransferLocal(ROOT);
+    call_user_func_array('Drupal\update_authorize_run_install', array_merge(array($filetransfer), $arguments));
   }
   // Otherwise, go through the regular workflow to prompt for FTP/SSH
   // credentials and invoke update_authorize_run_install() indirectly with
   // whatever FileTransfer object authorize.php creates for us.
   else {
-    system_authorized_init('update_authorize_run_install', drupal_get_path('module', 'update') . '/update.authorize.inc', $arguments, t('Update manager'));
+    system_authorized_init('update_authorize_run_install', get_path('module', 'update') . '/update.authorize.inc', $arguments, t('Update manager'));
     $form_state['redirect'] = system_authorized_get_url();
   }
 }
@@ -816,7 +818,7 @@ function update_manager_file_get($url) {
 
   // Check the cache and download the file if needed.
   $cache_directory = _update_manager_cache_directory();
-  $local = $cache_directory . '/' . drupal_basename($parsed_url['path']);
+  $local = $cache_directory . '/' . basename($parsed_url['path']);
 
   if (!file_exists($local) || update_delete_file_if_stale($local)) {
     return system_retrieve_file($url, $local, FALSE, FILE_EXISTS_REPLACE);
diff --git a/core/modules/update/update.module b/core/modules/update/update.module
index 6577af7..ef77652 100644
--- a/core/modules/update/update.module
+++ b/core/modules/update/update.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -136,10 +137,10 @@ function update_init() {
       if (!empty($verbose)) {
         if (isset($status[$type]['severity'])) {
           if ($status[$type]['severity'] == REQUIREMENT_ERROR) {
-            drupal_set_message($status[$type]['description'], 'error');
+            set_message($status[$type]['description'], 'error');
           }
           elseif ($status[$type]['severity'] == REQUIREMENT_WARNING) {
-            drupal_set_message($status[$type]['description'], 'warning');
+            set_message($status[$type]['description'], 'warning');
           }
         }
       }
@@ -149,7 +150,7 @@ function update_init() {
         if (isset($status[$type])
             && isset($status[$type]['reason'])
             && $status[$type]['reason'] === UPDATE_NOT_SECURE) {
-          drupal_set_message($status[$type]['description'], 'error');
+          set_message($status[$type]['description'], 'error');
         }
       }
     }
@@ -177,7 +178,7 @@ function update_menu() {
   );
   $items['admin/reports/updates/settings'] = array(
     'title' => 'Settings',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('update_settings'),
     'access arguments' => array('administer site configuration'),
     'file' => 'update.settings.inc',
@@ -205,7 +206,7 @@ function update_menu() {
   );
   foreach ($paths as $context => $path) {
     $items[$path . '/install'] = array(
-      'page callback' => 'drupal_get_form',
+      'page callback' => 'get_form',
       'page arguments' => array('update_manager_install_form', $context),
       'access callback' => 'update_manager_access',
       'access arguments' => array(),
@@ -214,7 +215,7 @@ function update_menu() {
       'file' => 'update.manager.inc',
     );
     $items[$path . '/update'] = array(
-      'page callback' => 'drupal_get_form',
+      'page callback' => 'get_form',
       'page arguments' => array('update_manager_update_form', $context),
       'access callback' => 'update_manager_access',
       'access arguments' => array(),
@@ -234,7 +235,7 @@ function update_menu() {
   // have been downloaded, asking you to backup before installing updates.
   $items['admin/update/ready'] = array(
     'title' => 'Ready to update',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('update_manager_update_ready_form'),
     'access callback' => 'update_manager_access',
     'access arguments' => array(),
@@ -350,7 +351,7 @@ function update_cache_clear_submit($form, &$form_state) {
  * Prints a warning message when there is no data about available updates.
  */
 function _update_no_data() {
-  $destination = drupal_get_destination();
+  $destination = get_destination();
   return t('No update information available. <a href="@run_cron">Run cron</a> or <a href="@check_manually">check manually</a>.', array(
     '@run_cron' => url('admin/reports/status/run-cron', array('query' => $destination)),
     '@check_manually' => url('admin/reports/updates/check', array('query' => $destination)),
@@ -493,7 +494,7 @@ function _update_get_cached_available_releases() {
  *   as the keys, and the status reason constant (UPDATE_NOT_SECURE, etc) for
  *   the values.
  *
- * @see drupal_mail()
+ * @see mail()
  * @see _update_cron_notify()
  * @see _update_message_text()
  */
@@ -638,7 +639,7 @@ function theme_update_last_check($variables) {
   $last = $variables['last'];
   $output = '<div class="update checked">';
   $output .= $last ? t('Last checked: @time ago', array('@time' => format_interval(REQUEST_TIME - $last))) : t('Last checked: never');
-  $output .= ' <span class="check-manually">(' . l(t('Check manually'), 'admin/reports/updates/check', array('query' => drupal_get_destination())) . ')</span>';
+  $output .= ' <span class="check-manually">(' . l(t('Check manually'), 'admin/reports/updates/check', array('query' => get_destination())) . ')</span>';
   $output .= "</div>\n";
   return $output;
 }
@@ -653,7 +654,7 @@ function theme_update_last_check($variables) {
  * an .info file which claims that the code is compatible with the current
  * version of Drupal core.
  *
- * @see drupal_system_listing()
+ * @see system_listing()
  * @see _system_rebuild_module_data()
  */
 function update_verify_update_archive($project, $archive_file, $directory) {
@@ -679,13 +680,13 @@ function update_verify_update_archive($project, $archive_file, $directory) {
   // functionality).
   $compatible_project = FALSE;
   $incompatible = array();
-  $files = file_scan_directory("$directory/$project", '/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info$/', array('key' => 'name', 'min_depth' => 0));
+  $files = file_scan_directory("$directory/$project", '/^' . PHP_FUNCTION_PATTERN . '\.info$/', array('key' => 'name', 'min_depth' => 0));
   foreach ($files as $key => $file) {
     // Get the .info file for the module or theme this file belongs to.
-    $info = drupal_parse_info_file($file->uri);
+    $info = parse_info_file($file->uri);
 
     // If the module or theme is incompatible with Drupal core, set an error.
-    if (empty($info['core']) || $info['core'] != DRUPAL_CORE_COMPATIBILITY) {
+    if (empty($info['core']) || $info['core'] != CORE_COMPATIBILITY) {
       $incompatible[] = !empty($info['name']) ? $info['name'] : t('Unknown');
     }
     else {
@@ -695,14 +696,14 @@ function update_verify_update_archive($project, $archive_file, $directory) {
   }
 
   if (empty($files)) {
-    $errors[] = t('%archive_file does not contain any .info files.', array('%archive_file' => drupal_basename($archive_file)));
+    $errors[] = t('%archive_file does not contain any .info files.', array('%archive_file' => basename($archive_file)));
   }
   elseif (!$compatible_project) {
     $errors[] = format_plural(
       count($incompatible),
       '%archive_file contains a version of %names that is not compatible with Drupal !version.',
       '%archive_file contains versions of modules or themes that are not compatible with Drupal !version: %names',
-      array('!version' => DRUPAL_CORE_COMPATIBILITY, '%archive_file' => drupal_basename($archive_file), '%names' => implode(', ', $incompatible))
+      array('!version' => CORE_COMPATIBILITY, '%archive_file' => basename($archive_file), '%names' => implode(', ', $incompatible))
     );
   }
 
@@ -866,7 +867,7 @@ function update_flush_caches() {
 function _update_manager_unique_identifier() {
   $id = &drupal_static(__FUNCTION__, '');
   if (empty($id)) {
-    $id = substr(hash('sha256', drupal_get_hash_salt()), 0, 8);
+    $id = substr(hash('sha256', get_hash_salt()), 0, 8);
   }
   return $id;
 }
@@ -951,7 +952,7 @@ function update_clear_update_disk_cache() {
 function update_delete_file_if_stale($path) {
   if (file_exists($path)) {
     $filectime = filectime($path);
-    if (REQUEST_TIME - $filectime > DRUPAL_MAXIMUM_TEMP_FILE_AGE || (preg_match('/.*-dev\.(tar\.gz|zip)/i', $path) && REQUEST_TIME - $filectime > 300)) {
+    if (REQUEST_TIME - $filectime > MAXIMUM_TEMP_FILE_AGE || (preg_match('/.*-dev\.(tar\.gz|zip)/i', $path) && REQUEST_TIME - $filectime > 300)) {
       file_unmanaged_delete_recursive($path);
     }
   }
diff --git a/core/modules/update/update.report.inc b/core/modules/update/update.report.inc
index 7703503..f997594 100644
--- a/core/modules/update/update.report.inc
+++ b/core/modules/update/update.report.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -170,7 +171,7 @@ function theme_update_report($variables) {
       foreach ($project['extra'] as $key => $value) {
         $row .= '<div class="' . implode(' ', $value['class']) . '">';
         $row .= check_plain($value['label']) . ': ';
-        $row .= drupal_placeholder($value['data']);
+        $row .= placeholder($value['data']);
         $row .= "</div>\n";
       }
       $row .= "</div>\n";  // extra div.
@@ -205,7 +206,7 @@ function theme_update_report($variables) {
             break;
 
           default:
-            $base_themes[] = drupal_placeholder($base_theme);
+            $base_themes[] = placeholder($base_theme);
         }
       }
       $row .= t('Depends on: !basethemes', array('!basethemes' => implode(', ', $base_themes)));
@@ -245,7 +246,7 @@ function theme_update_report($variables) {
       $output .= theme('table', array('header' => $header, 'rows' => $rows[$type_name], 'attributes' => array('class' => array('update'))));
     }
   }
-  drupal_add_css(drupal_get_path('module', 'update') . '/update.css');
+  add_css(get_path('module', 'update') . '/update.css');
   return $output;
 }
 
diff --git a/core/modules/update/update.settings.inc b/core/modules/update/update.settings.inc
index 60ac3ca..8abe336 100644
--- a/core/modules/update/update.settings.inc
+++ b/core/modules/update/update.settings.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/update/update.test b/core/modules/update/update.test
index a657f91..5b3e25e 100644
--- a/core/modules/update/update.test
+++ b/core/modules/update/update.test
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use SimpleXMLElement;
 
 /**
  * @file
@@ -22,7 +24,7 @@
 /**
  * Base class to define some shared functions used by all update tests.
  */
-class UpdateTestHelper extends DrupalWebTestCase {
+class UpdateTestHelper extends WebTestCase {
   /**
    * Refresh the update status based on the desired available update scenario.
    *
@@ -204,7 +206,7 @@ class UpdateCoreTestCase extends UpdateTestHelper {
     // Make sure duplicate messages don't appear on Update status pages.
     $this->drupalGet('admin/reports/status');
     // We're expecting "There is a security update..." inside the status report
-    // itself, but the drupal_set_message() appears as an li so we can prefix
+    // itself, but the set_message() appears as an li so we can prefix
     // with that and search for the raw HTML.
     $this->assertNoRaw('<li>' . t('There is a security update available for your version of Drupal.'));
 
@@ -637,7 +639,7 @@ class UpdateTestUploadCase extends UpdateTestHelper {
     // Check to ensure an existing module can't be reinstalled. Also checks that
     // the archive was extracted since we can't know if the module is already
     // installed until after extraction.
-    $validArchiveFile = drupal_get_path('module', 'update') . '/tests/aaa_update_test.tar.gz';
+    $validArchiveFile = get_path('module', 'update') . '/tests/aaa_update_test.tar.gz';
     $edit = array(
       'files[project_upload]' => $validArchiveFile,
     );
diff --git a/core/modules/user/tests/user_form_test.module b/core/modules/user/tests/user_form_test.module
index 4e907f3..df1d8bb 100644
--- a/core/modules/user/tests/user_form_test.module
+++ b/core/modules/user/tests/user_form_test.module
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -14,7 +15,7 @@ function user_form_test_menu() {
   $items = array();
   $items['user_form_test_current_password/%user'] = array(
     'title' => 'User form test for current password validation',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('user_form_test_current_password',1),
     'access arguments' => array('administer users'),
     'type' => MENU_SUGGESTED_ITEM,
@@ -60,5 +61,5 @@ function user_form_test_current_password($form, &$form_state, $account) {
  * Submit function for the test form for user_validate_current_pass().
  */
 function user_form_test_current_password_submit($form, &$form_state) {
-  drupal_set_message(t('The password has been validated and the form submitted successfully.'));
+  set_message(t('The password has been validated and the form submitted successfully.'));
 }
diff --git a/core/modules/user/user-picture.tpl.php b/core/modules/user/user-picture.tpl.php
index a33d266..ea5320c 100644
--- a/core/modules/user/user-picture.tpl.php
+++ b/core/modules/user/user-picture.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/user/user-profile.tpl.php b/core/modules/user/user-profile.tpl.php
index 940d47f..66265a8 100644
--- a/core/modules/user/user-profile.tpl.php
+++ b/core/modules/user/user-profile.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc
index f7d4552..b241e40 100644
--- a/core/modules/user/user.admin.inc
+++ b/core/modules/user/user.admin.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -11,15 +12,15 @@ function user_admin($callback_arg = '') {
   switch ($op) {
     case t('Create new account'):
     case 'create':
-      $build['user_register'] = drupal_get_form('user_register_form');
+      $build['user_register'] = get_form('user_register_form');
       break;
     default:
       if (!empty($_POST['accounts']) && isset($_POST['operation']) && ($_POST['operation'] == 'cancel')) {
-        $build['user_multiple_cancel_confirm'] = drupal_get_form('user_multiple_cancel_confirm');
+        $build['user_multiple_cancel_confirm'] = get_form('user_multiple_cancel_confirm');
       }
       else {
-        $build['user_filter_form'] = drupal_get_form('user_filter_form');
-        $build['user_admin_account'] = drupal_get_form('user_admin_account');
+        $build['user_filter_form'] = get_form('user_filter_form');
+        $build['user_admin_account'] = get_form('user_admin_account');
       }
   }
   return $build;
@@ -98,7 +99,7 @@ function user_filter_form() {
     );
   }
 
-  drupal_add_library('system', 'drupal.form');
+  add_library('system', 'drupal.form');
 
   return $form;
 }
@@ -188,10 +189,10 @@ function user_admin_account() {
     '#value' => t('Update'),
   );
 
-  $destination = drupal_get_destination();
+  $destination = get_destination();
 
   $status = array(t('blocked'), t('active'));
-  $roles = array_map('check_plain', user_roles(TRUE));
+  $roles = array_map('Drupal\check_plain', user_roles(TRUE));
   $accounts = array();
   foreach ($result as $account) {
     $users_roles = array();
@@ -230,7 +231,7 @@ function user_admin_account_submit($form, &$form_state) {
   $operation = $operations[$form_state['values']['operation']];
   // Filter out unchecked accounts.
   $accounts = array_filter($form_state['values']['accounts']);
-  if ($function = $operation['callback']) {
+  if ($operation['callback']) {
     // Add in callback arguments if present.
     if (isset($operation['callback arguments'])) {
       $args = array_merge(array($accounts), $operation['callback arguments']);
@@ -238,9 +239,9 @@ function user_admin_account_submit($form, &$form_state) {
     else {
       $args = array($accounts);
     }
-    call_user_func_array($function, $args);
+    call_user_func_array('Drupal\\' . $operation['callback'], $args);
 
-    drupal_set_message(t('The update has been performed.'));
+    set_message(t('The update has been performed.'));
   }
 }
 
@@ -280,8 +281,8 @@ function user_admin_settings() {
   // Do not allow users to set the anonymous or authenticated user roles as the
   // administrator role.
   $roles = user_roles();
-  unset($roles[DRUPAL_ANONYMOUS_RID]);
-  unset($roles[DRUPAL_AUTHENTICATED_RID]);
+  unset($roles[ANONYMOUS_RID]);
+  unset($roles[AUTHENTICATED_RID]);
   $roles[0] = t('disabled');
 
   $form['admin_role']['user_admin_role'] = array(
@@ -356,7 +357,7 @@ function user_admin_settings() {
     '#title' => t('Enable user pictures.'),
     '#default_value' => $picture_support,
   );
-  drupal_add_js(drupal_get_path('module', 'user') . '/user.js');
+  add_js(get_path('module', 'user') . '/user.js');
   $form['personalization']['pictures'] = array(
     '#type' => 'container',
     '#states' => array(
@@ -719,7 +720,7 @@ function user_admin_permissions($form, $form_state, $rid = NULL) {
   $form['actions'] = array('#type' => 'actions');
   $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save permissions'));
 
-  $form['#attached']['js'][] = drupal_get_path('module', 'user') . '/user.permissions.js';
+  $form['#attached']['js'][] = get_path('module', 'user') . '/user.permissions.js';
 
   return $form;
 }
@@ -734,7 +735,7 @@ function user_admin_permissions_submit($form, &$form_state) {
     user_role_change_permissions($rid, $form_state['values'][$rid]);
   }
 
-  drupal_set_message(t('The changes have been saved.'));
+  set_message(t('The changes have been saved.'));
 
   // Clear the cached pages and blocks.
   cache_clear_all();
@@ -779,7 +780,7 @@ function theme_user_admin_permissions($variables) {
   }
   $output = theme('system_compact_link');
   $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'permissions')));
-  $output .= drupal_render_children($form);
+  $output .= render_children($form);
   return $output;
 }
 
@@ -877,7 +878,7 @@ function user_admin_roles_order_submit($form, &$form_state) {
     $role->weight = $role_values['weight'];
     user_role_save($role);
   }
-  drupal_set_message(t('The role settings have been updated.'));
+  set_message(t('The role settings have been updated.'));
 }
 
 /**
@@ -896,7 +897,7 @@ function theme_user_admin_roles($variables) {
   foreach (element_children($form['roles']) as $rid) {
     $name = $form['roles'][$rid]['#role']->name;
     $row = array();
-    if (in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) {
+    if (in_array($rid, array(ANONYMOUS_RID, AUTHENTICATED_RID))) {
       $row[] = t('@name <em>(locked)</em>', array('@name' => $name));
       $row[] = drupal_render($form['roles'][$rid]['weight']);
       $row[] = '';
@@ -912,10 +913,10 @@ function theme_user_admin_roles($variables) {
   }
   $rows[] = array(array('data' => drupal_render($form['name']) . drupal_render($form['add']), 'colspan' => 4, 'class' => 'edit-name'));
 
-  drupal_add_tabledrag('user-roles', 'order', 'sibling', 'role-weight');
+  add_tabledrag('user-roles', 'order', 'sibling', 'role-weight');
 
   $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'user-roles')));
-  $output .= drupal_render_children($form);
+  $output .= render_children($form);
 
   return $output;
 }
@@ -928,8 +929,8 @@ function theme_user_admin_roles($variables) {
  * @see user_admin_role_submit()
  */
 function user_admin_role($form, $form_state, $role) {
-  if ($role->rid == DRUPAL_ANONYMOUS_RID || $role->rid == DRUPAL_AUTHENTICATED_RID) {
-    drupal_goto('admin/people/permissions/roles');
+  if ($role->rid == ANONYMOUS_RID || $role->rid == AUTHENTICATED_RID) {
+    redirect('admin/people/permissions/roles');
   }
 
   // Display the edit role form.
@@ -993,11 +994,11 @@ function user_admin_role_submit($form, &$form_state) {
   $role = (object) $form_state['values'];
   if ($form_state['values']['op'] == t('Save role')) {
     user_role_save($role);
-    drupal_set_message(t('The role has been renamed.'));
+    set_message(t('The role has been renamed.'));
   }
   elseif ($form_state['values']['op'] == t('Add role')) {
     user_role_save($role);
-    drupal_set_message(t('The role has been added.'));
+    set_message(t('The role has been added.'));
   }
   $form_state['redirect'] = 'admin/people/permissions/roles';
   return;
@@ -1026,7 +1027,7 @@ function user_admin_role_delete_confirm($form, &$form_state, $role) {
  */
 function user_admin_role_delete_confirm_submit($form, &$form_state) {
   user_role_delete((int) $form_state['values']['rid']);
-  drupal_set_message(t('The role has been deleted.'));
+  set_message(t('The role has been deleted.'));
   $form_state['redirect'] = 'admin/people/permissions/roles';
 }
 
diff --git a/core/modules/user/user.api.php b/core/modules/user/user.api.php
index 752d3d4..27eb5c6 100644
--- a/core/modules/user/user.api.php
+++ b/core/modules/user/user.api.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -68,7 +69,7 @@ function hook_user_predelete($account) {
  * @see user_delete_multiple()
  */
 function hook_user_delete($account) {
-  drupal_set_message(t('User: @name has been deleted.', array('@name' => $account->name)));
+  set_message(t('User: @name has been deleted.', array('@name' => $account->name)));
 }
 
 /**
@@ -306,7 +307,7 @@ function hook_user_update(&$edit, $account) {
 function hook_user_login(&$edit, $account) {
   // If the user has a NULL time zone, notify them to set a time zone.
   if (!$account->timezone && variable_get('configurable_timezones', 1) && variable_get('empty_timezone_message', 0)) {
-    drupal_set_message(t('Configure your <a href="@user-edit">account time zone setting</a>.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
+    set_message(t('Configure your <a href="@user-edit">account time zone setting</a>.', array('@user-edit' => url("user/$account->uid/edit", array('query' => get_destination(), 'fragment' => 'edit-timezone')))));
   }
 }
 
diff --git a/core/modules/user/user.entity.inc b/core/modules/user/user.entity.inc
index 5549c77..25a6feb 100644
--- a/core/modules/user/user.entity.inc
+++ b/core/modules/user/user.entity.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file Controller class for users.
@@ -7,10 +8,10 @@
 /**
  * Controller class for users.
  *
- * This extends the DrupalDefaultEntityController class, adding required
+ * This extends the DefaultEntityController class, adding required
  * special handling for user objects.
  */
-class UserController extends DrupalDefaultEntityController {
+class UserController extends DefaultEntityController {
 
   function attachLoad(&$queried_users, $revision_id = FALSE) {
     // Build an array of user picture IDs so that these can be fetched later.
@@ -20,10 +21,10 @@ class UserController extends DrupalDefaultEntityController {
       $queried_users[$key]->data = unserialize($record->data);
       $queried_users[$key]->roles = array();
       if ($record->uid) {
-        $queried_users[$record->uid]->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
+        $queried_users[$record->uid]->roles[AUTHENTICATED_RID] = 'authenticated user';
       }
       else {
-        $queried_users[$record->uid]->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user';
+        $queried_users[$record->uid]->roles[ANONYMOUS_RID] = 'anonymous user';
       }
     }
 
diff --git a/core/modules/user/user.install b/core/modules/user/user.install
index f7175c3..3beba01 100644
--- a/core/modules/user/user.install
+++ b/core/modules/user/user.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -322,15 +323,15 @@ function user_install() {
   // Sanity check to ensure the anonymous and authenticated role IDs are the
   // same as the drupal defined constants. In certain situations, this will
   // not be true.
-  if ($rid_anonymous != DRUPAL_ANONYMOUS_RID) {
+  if ($rid_anonymous != ANONYMOUS_RID) {
     db_update('role')
-      ->fields(array('rid' => DRUPAL_ANONYMOUS_RID))
+      ->fields(array('rid' => ANONYMOUS_RID))
       ->condition('rid', $rid_anonymous)
       ->execute();
   }
-  if ($rid_authenticated != DRUPAL_AUTHENTICATED_RID) {
+  if ($rid_authenticated != AUTHENTICATED_RID) {
     db_update('role')
-      ->fields(array('rid' => DRUPAL_AUTHENTICATED_RID))
+      ->fields(array('rid' => AUTHENTICATED_RID))
       ->condition('rid', $rid_authenticated)
       ->execute();
   }
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 832d29d..ed78ff3 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception, stdClass;
 
 /**
  * @file
@@ -96,7 +98,7 @@ function user_help($path, $arg) {
  */
 function user_module_invoke($type, &$edit, $account) {
   foreach (module_implements('user_' . $type) as $module) {
-    $function = $module . '_user_' . $type;
+    $function = 'Drupal\\' . $module . '_user_' . $type;
     $function($edit, $account);
   }
 }
@@ -303,7 +305,7 @@ function user_load_multiple($uids = array(), $conditions = array(), $reset = FAL
  * user. So to avoid confusion and to avoid clobbering the global $user object,
  * it is a good idea to assign the result of this function to a different local
  * variable, generally $account. If you actually do want to act as the user you
- * are loading, it is essential to call drupal_save_session(FALSE); first.
+ * are loading, it is essential to call save_session(FALSE); first.
  * See
  * @link http://drupal.org/node/218104 Safely impersonating another user @endlink
  * for more information.
@@ -382,7 +384,7 @@ function user_save($account, $edit = array()) {
   try {
     if (!empty($edit['pass'])) {
       // Allow alternate password hashing schemes.
-      require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'core/includes/password.inc');
+      require_once ROOT . '/' . variable_get('password_inc', 'core/includes/password.inc');
       $edit['pass'] = user_hash_password(trim($edit['pass']));
       // Abort if the hashing failed and returned FALSE.
       if (!$edit['pass']) {
@@ -458,7 +460,7 @@ function user_save($account, $edit = array()) {
       // Do not allow 'uid' to be changed.
       $account->uid = $account->original->uid;
       // Save changes to the user table.
-      $success = drupal_write_record('users', $account, 'uid');
+      $success = write_record('users', $account, 'uid');
       if ($success === FALSE) {
         // The query failed - better to abort the save than risk further
         // data loss.
@@ -473,7 +475,7 @@ function user_save($account, $edit = array()) {
 
         $query = db_insert('users_roles')->fields(array('uid', 'rid'));
         foreach (array_keys($account->roles) as $rid) {
-          if (!in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) {
+          if (!in_array($rid, array(ANONYMOUS_RID, AUTHENTICATED_RID))) {
             $query->values(array(
               'uid' => $account->uid,
               'rid' => $rid,
@@ -485,15 +487,15 @@ function user_save($account, $edit = array()) {
 
       // Delete a blocked user's sessions to kick them if they are online.
       if ($account->original->status != $account->status && $account->status == 0) {
-        drupal_session_destroy_uid($account->uid);
+        session_destroy_uid($account->uid);
       }
 
       // If the password changed, delete all open sessions and recreate
       // the current one.
       if ($account->pass != $account->original->pass) {
-        drupal_session_destroy_uid($account->uid);
+        session_destroy_uid($account->uid);
         if ($account->uid == $GLOBALS['user']->uid) {
-          drupal_session_regenerate();
+          session_regenerate();
         }
       }
 
@@ -518,7 +520,7 @@ function user_save($account, $edit = array()) {
     }
     else {
       // Allow 'uid' to be set by the caller. There is no danger of writing an
-      // existing user as drupal_write_record will do an INSERT.
+      // existing user as write_record will do an INSERT.
       if (empty($account->uid)) {
         $account->uid = db_next_id(db_query('SELECT MAX(uid) FROM {users}')->fetchField());
       }
@@ -526,7 +528,7 @@ function user_save($account, $edit = array()) {
       if (!isset($account->created)) {
         $account->created = REQUEST_TIME;
       }
-      $success = drupal_write_record('users', $account);
+      $success = write_record('users', $account);
       if ($success === FALSE) {
         // On a failed INSERT some other existing user's uid may be returned.
         // We must abort to avoid overwriting their account.
@@ -534,7 +536,7 @@ function user_save($account, $edit = array()) {
       }
 
       // Make sure $account is properly initialized.
-      $account->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
+      $account->roles[AUTHENTICATED_RID] = 'authenticated user';
 
       field_attach_insert('user', $account);
       $edit = (array) $account;
@@ -545,7 +547,7 @@ function user_save($account, $edit = array()) {
       if (count($account->roles) > 1) {
         $query = db_insert('users_roles')->fields(array('uid', 'rid'));
         foreach (array_keys($account->roles) as $rid) {
-          if (!in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) {
+          if (!in_array($rid, array(ANONYMOUS_RID, AUTHENTICATED_RID))) {
             $query->values(array(
               'uid' => $account->uid,
               'rid' => $rid,
@@ -754,11 +756,11 @@ function user_access($string, $account = NULL) {
   // To reduce the number of SQL queries, we cache the user's permissions
   // in a static variable.
   // Use the advanced drupal_static() pattern, since this is called very often.
-  static $drupal_static_fast;
-  if (!isset($drupal_static_fast)) {
-    $drupal_static_fast['perm'] = &drupal_static(__FUNCTION__);
+  static $static_fast;
+  if (!isset($static_fast)) {
+    $static_fast['perm'] = &drupal_static(__FUNCTION__);
   }
-  $perm = &$drupal_static_fast['perm'];
+  $perm = &$static_fast['perm'];
   if (!isset($perm[$account->uid])) {
     $role_permissions = user_role_permissions($account->roles);
 
@@ -1033,7 +1035,7 @@ function user_account_form(&$form, &$form_state) {
     '#access' => $admin,
   );
 
-  $roles = array_map('check_plain', user_roles(TRUE));
+  $roles = array_map('Drupal\check_plain', user_roles(TRUE));
   // The disabled checkbox subelement for the 'authenticated user' role
   // must be generated separately and added to the checkboxes element,
   // because of a limitation in Form API not supporting a single disabled
@@ -1041,18 +1043,18 @@ function user_account_form(&$form, &$form_state) {
   // @todo This should be solved more elegantly. See issue #119038.
   $checkbox_authenticated = array(
     '#type' => 'checkbox',
-    '#title' => $roles[DRUPAL_AUTHENTICATED_RID],
+    '#title' => $roles[AUTHENTICATED_RID],
     '#default_value' => TRUE,
     '#disabled' => TRUE,
   );
-  unset($roles[DRUPAL_AUTHENTICATED_RID]);
+  unset($roles[AUTHENTICATED_RID]);
   $form['account']['roles'] = array(
     '#type' => 'checkboxes',
     '#title' => t('Roles'),
     '#default_value' => (!$register && isset($account->roles) ? array_keys($account->roles) : array()),
     '#options' => $roles,
     '#access' => $roles && user_access('administer permissions'),
-    DRUPAL_AUTHENTICATED_RID => $checkbox_authenticated,
+    AUTHENTICATED_RID => $checkbox_authenticated,
   );
 
   $form['account']['notify'] = array(
@@ -1118,7 +1120,7 @@ function user_validate_current_pass(&$form, &$form_state) {
     // form values like password_confirm that have their own validation
     // that prevent them from being empty if they are changed.
     if ((strlen(trim($form_state['values'][$key])) > 0) && ($form_state['values'][$key] != $account->$key)) {
-      require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'core/includes/password.inc');
+      require_once ROOT . '/' . variable_get('password_inc', 'core/includes/password.inc');
       $current_pass_failed = empty($form_state['values']['current_pass']) || !user_check_password($form_state['values']['current_pass'], $account);
       if ($current_pass_failed) {
         form_set_error('current_pass', t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => $name)));
@@ -1174,7 +1176,7 @@ function user_account_form_validate($form, &$form_state) {
     // Move text value for user signature into 'signature'.
     $form_state['values']['signature'] = $form_state['values']['signature']['value'];
 
-    $user_schema = drupal_get_schema('users');
+    $user_schema = get_schema('users');
     if (drupal_strlen($form_state['values']['signature']) > $user_schema['fields']['signature']['length']) {
       form_set_error('signature', t('The signature is too long: it must be %max characters or less.', array('%max' => $user_schema['fields']['signature']['length'])));
     }
@@ -1206,7 +1208,7 @@ function user_user_presave(&$edit, $account) {
 }
 
 function user_login_block($form) {
-  $form['#action'] = url($_GET['q'], array('query' => drupal_get_destination()));
+  $form['#action'] = url($_GET['q'], array('query' => get_destination()));
   $form['#id'] = 'user-login-form';
   $form['#validate'] = user_login_default_validators();
   $form['#submit'][] = 'user_login_submit';
@@ -1243,14 +1245,14 @@ function user_block_info() {
 
   $blocks['login']['info'] = t('User login');
   // Not worth caching.
-  $blocks['login']['cache'] = DRUPAL_NO_CACHE;
+  $blocks['login']['cache'] = NO_CACHE;
 
   $blocks['new']['info'] = t('Who\'s new');
   $blocks['new']['properties']['administrative'] = TRUE;
 
   // Too dynamic to cache.
   $blocks['online']['info'] = t('Who\'s online');
-  $blocks['online']['cache'] = DRUPAL_NO_CACHE;
+  $blocks['online']['cache'] = NO_CACHE;
   $blocks['online']['properties']['administrative'] = TRUE;
 
   return $blocks;
@@ -1268,14 +1270,14 @@ function user_block_configure($delta = '') {
         '#type' => 'select',
         '#title' => t('Number of users to display'),
         '#default_value' => variable_get('user_block_whois_new_count', 5),
-        '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)),
+        '#options' => map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)),
       );
       return $form;
 
     case 'online':
-      $period = drupal_map_assoc(array(30, 60, 120, 180, 300, 600, 900, 1800, 2700, 3600, 5400, 7200, 10800, 21600, 43200, 86400), 'format_interval');
+      $period = map_assoc(array(30, 60, 120, 180, 300, 600, 900, 1800, 2700, 3600, 5400, 7200, 10800, 21600, 43200, 86400), 'Drupal\format_interval');
       $form['user_block_seconds_online'] = array('#type' => 'select', '#title' => t('User activity'), '#default_value' => variable_get('user_block_seconds_online', 900), '#options' => $period, '#description' => t('A user is considered online for this long after they have last viewed a page.'));
-      $form['user_block_max_list_count'] = array('#type' => 'select', '#title' => t('User list length'), '#default_value' => variable_get('user_block_max_list_count', 10), '#options' => drupal_map_assoc(array(0, 5, 10, 15, 20, 25, 30, 40, 50, 75, 100)), '#description' => t('Maximum number of currently online users to display.'));
+      $form['user_block_max_list_count'] = array('#type' => 'select', '#title' => t('User list length'), '#default_value' => variable_get('user_block_max_list_count', 10), '#options' => map_assoc(array(0, 5, 10, 15, 20, 25, 30, 40, 50, 75, 100)), '#description' => t('Maximum number of currently online users to display.'));
       return $form;
   }
 }
@@ -1312,7 +1314,7 @@ function user_block_view($delta = '') {
       if (!$user->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))) {
 
         $block['subject'] = t('User login');
-        $block['content'] = drupal_get_form('user_login_block');
+        $block['content'] = get_form('user_login_block');
       }
       return $block;
 
@@ -1391,7 +1393,7 @@ function user_preprocess_block(&$variables) {
  */
 function user_format_name($account) {
   $name = !empty($account->name) ? $account->name : variable_get('anonymous', t('Anonymous'));
-  drupal_alter('user_format_name', $name, $account);
+  alter('user_format_name', $name, $account);
   return $name;
 }
 
@@ -1533,7 +1535,7 @@ function template_process_username(&$variables) {
  *   - link_options: An array of options to pass to the l() function's $options
  *     parameter if linking the user's name to the user's page.
  *   - attributes_array: An array of attributes to pass to the
- *     drupal_attributes() function if not linking to the user's page.
+ *     attributes() function if not linking to the user's page.
  *
  * @see template_preprocess_username()
  * @see template_process_username()
@@ -1549,7 +1551,7 @@ function theme_username($variables) {
     // Modules may have added important attributes so they must be included
     // in the output. Additional classes may be added as array elements like
     // $variables['attributes_array']['class'][] = 'myclass';
-    $output = '<span' . drupal_attributes($variables['attributes_array']) . '>' . $variables['name'] . $variables['extra'] . '</span>';
+    $output = '<span' . attributes($variables['attributes_array']) . '>' . $variables['name'] . $variables['extra'] . '</span>';
   }
   return $output;
 }
@@ -1666,7 +1668,7 @@ function user_menu() {
 
   $items['user/register'] = array(
     'title' => 'Create new account',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('user_register_form'),
     'access callback' => 'user_register_access',
     'type' => MENU_LOCAL_TASK,
@@ -1674,7 +1676,7 @@ function user_menu() {
 
   $items['user/password'] = array(
     'title' => 'Request new password',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('user_pass'),
     'access callback' => TRUE,
     'type' => MENU_LOCAL_TASK,
@@ -1682,7 +1684,7 @@ function user_menu() {
   );
   $items['user/reset/%/%/%'] = array(
     'title' => 'Reset password',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('user_pass_reset', 2, 3, 4),
     'access callback' => TRUE,
     'type' => MENU_CALLBACK,
@@ -1722,7 +1724,7 @@ function user_menu() {
   $items['admin/people/permissions'] = array(
     'title' => 'Permissions',
     'description' => 'Determine access to features by selecting permissions for roles.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('user_admin_permissions'),
     'access arguments' => array('administer permissions'),
     'file' => 'user.admin.inc',
@@ -1737,7 +1739,7 @@ function user_menu() {
   $items['admin/people/permissions/roles'] = array(
     'title' => 'Roles',
     'description' => 'List, edit, or add user roles.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('user_admin_roles'),
     'access arguments' => array('administer permissions'),
     'file' => 'user.admin.inc',
@@ -1752,7 +1754,7 @@ function user_menu() {
   );
   $items['admin/people/permissions/roles/delete/%user_role'] = array(
     'title' => 'Delete role',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('user_admin_role_delete_confirm', 5),
     'access callback' => 'user_role_edit_access',
     'access arguments' => array(5),
@@ -1775,12 +1777,12 @@ function user_menu() {
    'page callback' => 'system_admin_menu_block_page',
    'access arguments' => array('access administration pages'),
    'file' => 'system.admin.inc',
-   'file path' => drupal_get_path('module', 'system'),
+   'file path' => get_path('module', 'system'),
   );
   $items['admin/config/people/accounts'] = array(
     'title' => 'Account settings',
     'description' => 'Configure default behavior of users, including registration requirements, e-mails, fields, and user pictures.',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('user_admin_settings'),
     'access arguments' => array('administer users'),
     'file' => 'user.admin.inc',
@@ -1816,7 +1818,7 @@ function user_menu() {
 
   $items['user/%user/cancel'] = array(
     'title' => 'Cancel account',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('user_cancel_confirm_form', 1),
     'access callback' => 'user_cancel_access',
     'access arguments' => array(1),
@@ -1834,7 +1836,7 @@ function user_menu() {
 
   $items['user/%user/edit'] = array(
     'title' => 'Edit',
-    'page callback' => 'drupal_get_form',
+    'page callback' => 'get_form',
     'page arguments' => array('user_profile_form', 1),
     'access callback' => 'user_edit_access',
     'access arguments' => array(1),
@@ -1859,7 +1861,7 @@ function user_menu_site_status_alter(&$menu_site_status, $path) {
       switch ($path) {
         case 'user':
           // Forward anonymous user to login page.
-          drupal_goto('user/login');
+          redirect('user/login');
         case 'user/login':
         case 'user/password':
           // Disable offline mode.
@@ -1877,11 +1879,11 @@ function user_menu_site_status_alter(&$menu_site_status, $path) {
   if (user_is_logged_in()) {
     if ($path == 'user/login') {
       // If user is logged in, redirect to 'user' instead of giving 403.
-      drupal_goto('user');
+      redirect('user');
     }
     if ($path == 'user/register') {
       // Authenticated user should be redirected to user edit page.
-      drupal_goto('user/' . $GLOBALS['user']->uid . '/edit');
+      redirect('user/' . $GLOBALS['user']->uid . '/edit');
     }
   }
 }
@@ -2043,7 +2045,7 @@ function user_login($form, &$form_state) {
 
   // If we are already logged on, go to the user page instead.
   if ($user->uid) {
-    drupal_goto('user/' . $user->uid);
+    redirect('user/' . $user->uid);
   }
 
   // Display login form:
@@ -2197,7 +2199,7 @@ function user_authenticate($name, $password) {
     $account = user_load_by_name($name);
     if ($account) {
       // Allow alternate password hashing schemes.
-      require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'core/includes/password.inc');
+      require_once ROOT . '/' . variable_get('password_inc', 'core/includes/password.inc');
       if (user_check_password($password, $account)) {
         // Successful authentication.
         $uid = $account->uid;
@@ -2232,7 +2234,7 @@ function user_login_finalize(&$edit = array()) {
   // Regenerate the session ID to prevent against session fixation attacks.
   // This is called before hook_user in case one of those functions fails
   // or incorrectly does a redirect which would leave the old session in place.
-  drupal_session_regenerate();
+  session_regenerate();
 
   user_module_invoke('login', $edit, $user);
 }
@@ -2266,10 +2268,10 @@ function user_external_login_register($name, $module) {
       'status' => 1,
       'access' => REQUEST_TIME
     );
-    $account = user_save(drupal_anonymous_user(), $userinfo);
+    $account = user_save(anonymous_user(), $userinfo);
     // Terminate if an error occurred during user_save().
     if (!$account) {
-      drupal_set_message(t("Error saving user account."), 'error');
+      set_message(t("Error saving user account."), 'error');
       return;
     }
     user_set_authmaps($account, array("authname_$module" => $name));
@@ -2339,7 +2341,7 @@ function user_cancel_url($account) {
  *   A string that is safe for use in URLs and SQL statements.
  */
 function user_pass_rehash($password, $timestamp, $login) {
-  return drupal_hmac_base64($timestamp . $login, drupal_get_hash_salt() . $password);
+  return hmac_base64($timestamp . $login, get_hash_salt() . $password);
 }
 
 /**
@@ -2364,7 +2366,7 @@ function user_cancel($edit, $uid, $method) {
   $account = user_load($uid);
 
   if (!$account) {
-    drupal_set_message(t('The user account %id does not exist.', array('%id' => $uid)), 'error');
+    set_message(t('The user account %id does not exist.', array('%id' => $uid)), 'error');
     watchdog('user', 'Attempted to cancel non-existing user account: %id.', array('%id' => $uid), WATCHDOG_ERROR);
     return;
   }
@@ -2417,7 +2419,7 @@ function _user_cancel($edit, $account, $method) {
         _user_mail_notify('status_blocked', $account);
       }
       user_save($account, array('status' => 0));
-      drupal_set_message(t('%name has been disabled.', array('%name' => $account->name)));
+      set_message(t('%name has been disabled.', array('%name' => $account->name)));
       watchdog('user', 'Blocked user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
       break;
 
@@ -2428,7 +2430,7 @@ function _user_cancel($edit, $account, $method) {
         _user_mail_notify('status_canceled', $account);
       }
       user_delete($account->uid);
-      drupal_set_message(t('%name has been deleted.', array('%name' => $account->name)));
+      set_message(t('%name has been deleted.', array('%name' => $account->name)));
       watchdog('user', 'Deleted user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
       break;
   }
@@ -2474,7 +2476,7 @@ function user_delete_multiple(array $uids) {
         module_invoke_all('entity_predelete', $account, 'user');
 
         field_attach_delete('user', $account);
-        drupal_session_destroy_uid($account->uid);
+        session_destroy_uid($account->uid);
       }
 
       db_delete('users')
@@ -2556,7 +2558,7 @@ function user_view($account, $view_mode = 'full', $langcode = NULL) {
 
   // Allow modules to modify the structured user.
   $type = 'user';
-  drupal_alter(array('user_view', 'entity_view'), $build, $type);
+  alter(array('user_view', 'entity_view'), $build, $type);
 
   return $build;
 }
@@ -2811,7 +2813,7 @@ function user_roles($membersonly = FALSE, $permission = NULL) {
   // Do not cache roles for specific permissions. This data is not requested
   // frequently enough to justify the additional memory use.
   if (empty($permission)) {
-    $cid = $membersonly ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID;
+    $cid = $membersonly ? AUTHENTICATED_RID : ANONYMOUS_RID;
     if (isset($user_roles[$cid])) {
       return $user_roles[$cid];
     }
@@ -2832,12 +2834,12 @@ function user_roles($membersonly = FALSE, $permission = NULL) {
   foreach ($result as $role) {
     switch ($role->rid) {
       // We only translate the built in role names
-      case DRUPAL_ANONYMOUS_RID:
+      case ANONYMOUS_RID:
         if (!$membersonly) {
           $roles[$role->rid] = t($role->name);
         }
         break;
-      case DRUPAL_AUTHENTICATED_RID:
+      case AUTHENTICATED_RID:
         $roles[$role->rid] = t($role->name);
         break;
       default:
@@ -2921,17 +2923,17 @@ function user_role_save($role) {
   module_invoke_all('user_role_presave', $role);
 
   if (!empty($role->rid) && $role->name) {
-    $status = drupal_write_record('role', $role, 'rid');
+    $status = write_record('role', $role, 'rid');
     module_invoke_all('user_role_update', $role);
   }
   else {
-    $status = drupal_write_record('role', $role);
+    $status = write_record('role', $role);
     module_invoke_all('user_role_insert', $role);
   }
 
   // Clear the user access cache.
-  drupal_static_reset('user_access');
-  drupal_static_reset('user_role_permissions');
+  drupal_static_reset('Drupal\user_access');
+  drupal_static_reset('Drupal\user_role_permissions');
 
   return $status;
 }
@@ -2964,8 +2966,8 @@ function user_role_delete($role) {
   module_invoke_all('user_role_delete', $role);
 
   // Clear the user access cache.
-  drupal_static_reset('user_access');
-  drupal_static_reset('user_role_permissions');
+  drupal_static_reset('Drupal\user_access');
+  drupal_static_reset('Drupal\user_role_permissions');
 }
 
 /**
@@ -2973,7 +2975,7 @@ function user_role_delete($role) {
  */
 function user_role_edit_access($role) {
   // Prevent the system-defined roles from being altered or removed.
-  if ($role->rid == DRUPAL_ANONYMOUS_RID || $role->rid == DRUPAL_AUTHENTICATED_RID) {
+  if ($role->rid == ANONYMOUS_RID || $role->rid == AUTHENTICATED_RID) {
     return FALSE;
   }
 
@@ -3066,8 +3068,8 @@ function user_role_grant_permissions($rid, array $permissions = array()) {
   }
 
   // Clear the user access cache.
-  drupal_static_reset('user_access');
-  drupal_static_reset('user_role_permissions');
+  drupal_static_reset('Drupal\user_access');
+  drupal_static_reset('Drupal\user_role_permissions');
 }
 
 /**
@@ -3089,8 +3091,8 @@ function user_role_revoke_permissions($rid, array $permissions = array()) {
     ->execute();
 
   // Clear the user access cache.
-  drupal_static_reset('user_access');
-  drupal_static_reset('user_role_permissions');
+  drupal_static_reset('Drupal\user_access');
+  drupal_static_reset('Drupal\user_role_permissions');
 }
 
 /**
@@ -3113,7 +3115,7 @@ function user_user_operations($form = array(), $form_state = array()) {
 
   if (user_access('administer permissions')) {
     $roles = user_roles(TRUE);
-    unset($roles[DRUPAL_AUTHENTICATED_RID]);  // Can't edit authenticated role.
+    unset($roles[AUTHENTICATED_RID]);  // Can't edit authenticated role.
 
     $add_roles = array();
     foreach ($roles as $key => $value) {
@@ -3251,10 +3253,10 @@ function user_multiple_cancel_confirm($form, &$form_state) {
   if (isset($accounts[1])) {
     $redirect = (count($accounts) == 1);
     $message = t('The user account %name cannot be cancelled.', array('%name' => $accounts[1]->name));
-    drupal_set_message($message, $redirect ? 'error' : 'warning');
+    set_message($message, $redirect ? 'error' : 'warning');
     // If only user 1 was selected, redirect to the overview.
     if ($redirect) {
-      drupal_goto('admin/people');
+      redirect('admin/people');
     }
   }
 
@@ -3330,7 +3332,7 @@ function user_filters() {
   // Regular filters
   $filters = array();
   $roles = user_roles(TRUE);
-  unset($roles[DRUPAL_AUTHENTICATED_RID]); // Don't list authorized role.
+  unset($roles[AUTHENTICATED_RID]); // Don't list authorized role.
   if (count($roles)) {
     $filters['role'] = array(
       'title' => t('role'),
@@ -3343,7 +3345,7 @@ function user_filters() {
 
   $options = array();
   foreach (module_implements('permission') as $module) {
-    $function = $module . '_permission';
+    $function = 'Drupal\\' . $module . '_permission';
     if ($permissions = $function('permission')) {
       asort($permissions);
       foreach ($permissions as $permission => $description) {
@@ -3388,7 +3390,7 @@ function user_build_filter_query(SelectQuery $query) {
     if ($key == 'permission') {
       $account = new stdClass();
       $account->uid = 'user_filter';
-      $account->roles = array(DRUPAL_AUTHENTICATED_RID => 1);
+      $account->roles = array(AUTHENTICATED_RID => 1);
       if (user_access($value, $account)) {
         continue;
       }
@@ -3482,7 +3484,7 @@ function user_preferred_language($account, $default = NULL) {
  * operation happens on the given user account.
  *
  * @see user_mail_tokens()
- * @see drupal_mail()
+ * @see mail()
  *
  * @param $op
  *  The operation being performed on the account. Possible values:
@@ -3501,7 +3503,7 @@ function user_preferred_language($account, $default = NULL) {
  * @param $language
  *  Optional language to use for the notification, overriding account language.
  * @return
- *  The return value from drupal_mail_system()->mail(), if ends up being called.
+ *  The return value from mail_system()->mail(), if ends up being called.
  */
 function _user_mail_notify($op, $account, $language = NULL) {
   // By default, we always notify except for canceled and blocked.
@@ -3510,11 +3512,11 @@ function _user_mail_notify($op, $account, $language = NULL) {
   if ($notify) {
     $params['account'] = $account;
     $language = $language ? $language : user_preferred_language($account);
-    $mail = drupal_mail('user', $op, $account->mail, $language, $params);
+    $mail = mail('user', $op, $account->mail, $language, $params);
     if ($op == 'register_pending_approval') {
       // If a user registered requiring admin approval, notify the admin, too.
       // We use the site default language for this.
-      drupal_mail('user', 'register_pending_approval_admin', variable_get('site_mail', ini_get('sendmail_from')), language_default(), $params);
+      mail('user', 'register_pending_approval_admin', variable_get('site_mail', ini_get('sendmail_from')), language_default(), $params);
     }
   }
   return empty($mail) ? NULL : $mail['result'];
@@ -3553,7 +3555,7 @@ function user_form_process_password_confirm($element) {
     ),
   );
 
-  $element['#attached']['js'][] = drupal_get_path('module', 'user') . '/user.js';
+  $element['#attached']['js'][] = get_path('module', 'user') . '/user.js';
   // Ensure settings are only added once per page.
   static $already_added = FALSE;
   if (!$already_added) {
@@ -3669,7 +3671,7 @@ function user_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id
       // a custom behavior, since the #states system would also synchronize on
       // uncheck.
       '#attached' => array(
-        'js' => array(drupal_get_path('module', 'user') . '/user.js'),
+        'js' => array(get_path('module', 'user') . '/user.js'),
       ),
     );
 
@@ -3705,10 +3707,10 @@ function user_register_form($form, &$form_state) {
 
   // If we aren't admin but already logged on, go to the user page instead.
   if (!$admin && $user->uid) {
-    drupal_goto('user/' . $user->uid);
+    redirect('user/' . $user->uid);
   }
 
-  $form['#user'] = drupal_anonymous_user();
+  $form['#user'] = anonymous_user();
 
   $form['#attached']['library'][] = array('system', 'jquery.cookie');
   $form['#attributes']['class'][] = 'user-info-from-cookie';
@@ -3787,7 +3789,7 @@ function user_register_submit($form, &$form_state) {
 
   // Terminate if an error occurred during user_save().
   if (!$account) {
-    drupal_set_message(t("Error saving user account."), 'error');
+    set_message(t("Error saving user account."), 'error');
     $form_state['redirect'] = '';
     return;
   }
@@ -3802,14 +3804,14 @@ function user_register_submit($form, &$form_state) {
   // New administrative account without notification.
   $uri = entity_uri('user', $account);
   if ($admin && !$notify) {
-    drupal_set_message(t('Created a new user account for <a href="@url">%name</a>. No e-mail has been sent.', array('@url' => url($uri['path'], $uri['options']), '%name' => $account->name)));
+    set_message(t('Created a new user account for <a href="@url">%name</a>. No e-mail has been sent.', array('@url' => url($uri['path'], $uri['options']), '%name' => $account->name)));
   }
   // No e-mail verification required; log in user immediately.
   elseif (!$admin && !variable_get('user_email_verification', TRUE) && $account->status) {
     _user_mail_notify('register_no_approval_required', $account);
     $form_state['uid'] = $account->uid;
     user_login_submit(array(), $form_state);
-    drupal_set_message(t('Registration successful. You are now logged in.'));
+    set_message(t('Registration successful. You are now logged in.'));
     $form_state['redirect'] = '';
   }
   // No administrator approval required.
@@ -3817,17 +3819,17 @@ function user_register_submit($form, &$form_state) {
     $op = $notify ? 'register_admin_created' : 'register_no_approval_required';
     _user_mail_notify($op, $account);
     if ($notify) {
-      drupal_set_message(t('A welcome message with further instructions has been e-mailed to the new user <a href="@url">%name</a>.', array('@url' => url($uri['path'], $uri['options']), '%name' => $account->name)));
+      set_message(t('A welcome message with further instructions has been e-mailed to the new user <a href="@url">%name</a>.', array('@url' => url($uri['path'], $uri['options']), '%name' => $account->name)));
     }
     else {
-      drupal_set_message(t('A welcome message with further instructions has been sent to your e-mail address.'));
+      set_message(t('A welcome message with further instructions has been sent to your e-mail address.'));
       $form_state['redirect'] = '';
     }
   }
   // Administrator approval required.
   else {
     _user_mail_notify('register_pending_approval', $account);
-    drupal_set_message(t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />In the meantime, a welcome message with further instructions has been sent to your e-mail address.'));
+    set_message(t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />In the meantime, a welcome message with further instructions has been sent to your e-mail address.'));
     $form_state['redirect'] = '';
   }
 }
@@ -3867,7 +3869,7 @@ function user_modules_uninstalled($modules) {
  * proper destination after a user has been properly logged in.
  */
 function user_login_destination() {
-  $destination = drupal_get_destination();
+  $destination = get_destination();
   if ($destination['destination'] == 'user/login') {
     $destination['destination'] = 'user';
   }
diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc
index 8239c53..2f5ae6b 100644
--- a/core/modules/user/user.pages.inc
+++ b/core/modules/user/user.pages.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -17,7 +18,7 @@ function user_autocomplete($string = '') {
     }
   }
 
-  drupal_json_output($matches);
+  json_output($matches);
 }
 
 /**
@@ -79,7 +80,7 @@ function user_pass_submit($form, &$form_state) {
   $mail = _user_mail_notify('password_reset', $account, $language);
   if (!empty($mail)) {
     watchdog('user', 'Password reset instructions mailed to %name at %email.', array('%name' => $account->name, '%email' => $account->mail));
-    drupal_set_message(t('Further instructions have been sent to your e-mail address.'));
+    set_message(t('Further instructions have been sent to your e-mail address.'));
   }
 
   $form_state['redirect'] = 'user';
@@ -97,20 +98,20 @@ function user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $a
   if ($user->uid) {
     // The existing user is already logged in.
     if ($user->uid == $uid) {
-      drupal_set_message(t('You are logged in as %user. <a href="!user_edit">Change your password.</a>', array('%user' => $user->name, '!user_edit' => url("user/$user->uid/edit"))));
+      set_message(t('You are logged in as %user. <a href="!user_edit">Change your password.</a>', array('%user' => $user->name, '!user_edit' => url("user/$user->uid/edit"))));
     }
     // A different user is already logged in on the computer.
     else {
       $reset_link_account = user_load($uid);
       if (!empty($reset_link_account)) {
-        drupal_set_message(t('Another user (%other_user) is already logged into the site on this computer, but you tried to use a one-time link for user %resetting_user. Please <a href="!logout">logout</a> and try using the link again.',
+        set_message(t('Another user (%other_user) is already logged into the site on this computer, but you tried to use a one-time link for user %resetting_user. Please <a href="!logout">logout</a> and try using the link again.',
           array('%other_user' => $user->name, '%resetting_user' => $reset_link_account->name, '!logout' => url('user/logout'))));
       } else {
         // Invalid one-time link specifies an unknown user.
-        drupal_set_message(t('The one-time login link you clicked is invalid.'));
+        set_message(t('The one-time login link you clicked is invalid.'));
       }
     }
-    drupal_goto();
+    redirect();
   }
   else {
     // Time out, in seconds, until login URL expires. 24 hours = 86400 seconds.
@@ -121,8 +122,8 @@ function user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $a
     if ($timestamp <= $current && $account = reset($users)) {
       // No time out for first time login.
       if ($account->login && $current - $timestamp > $timeout) {
-        drupal_set_message(t('You have tried to use a one-time login link that has expired. Please request a new one using the form below.'));
-        drupal_goto('user/password');
+        set_message(t('You have tried to use a one-time login link that has expired. Please request a new one using the form below.'));
+        redirect('user/password');
       }
       elseif ($account->uid && $timestamp >= $account->login && $timestamp <= $current && $hashed_pass == user_pass_rehash($account->pass, $timestamp, $account->login)) {
         // First stage is a confirmation form, then login
@@ -133,11 +134,11 @@ function user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $a
           // user_login_finalize() also updates the login timestamp of the
           // user, which invalidates further use of the one-time login link.
           user_login_finalize();
-          drupal_set_message(t('You have just used your one-time login link. It is no longer necessary to use this link to log in. Please change your password.'));
+          set_message(t('You have just used your one-time login link. It is no longer necessary to use this link to log in. Please change your password.'));
           // Let the user's password be changed without the current password check.
-          $token = drupal_hash_base64(drupal_random_bytes(55));
+          $token = hash_base64(random_bytes(55));
           $_SESSION['pass_reset_' . $user->uid] = $token;
-          drupal_goto('user/' . $user->uid . '/edit', array('query' => array('pass-reset-token' => $token)));
+          redirect('user/' . $user->uid . '/edit', array('query' => array('pass-reset-token' => $token)));
         }
         else {
           $form['message'] = array('#markup' => t('<p>This is a one-time login for %user_name and will expire on %expiration_date.</p><p>Click on this button to log in to the site and change your password.</p>', array('%user_name' => $account->name, '%expiration_date' => format_date($timestamp + $timeout))));
@@ -149,14 +150,14 @@ function user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $a
         }
       }
       else {
-        drupal_set_message(t('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.'));
-        drupal_goto('user/password');
+        set_message(t('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.'));
+        redirect('user/password');
       }
     }
     else {
       // Deny access, no more clues.
       // Everything will be in the watchdog's URL for the administrator to check.
-      drupal_access_denied();
+      access_denied();
     }
   }
 }
@@ -174,7 +175,7 @@ function user_logout() {
   // Destroy the current session, and reset $user to the anonymous user.
   session_destroy();
 
-  drupal_goto();
+  redirect();
 }
 
 /**
@@ -285,7 +286,7 @@ function user_profile_form_submit($form, &$form_state) {
   // Clear the page cache because pages can contain usernames and/or profile information:
   cache_clear_all();
 
-  drupal_set_message(t('The changes have been saved.'));
+  set_message(t('The changes have been saved.'));
 }
 
 /**
@@ -294,7 +295,7 @@ function user_profile_form_submit($form, &$form_state) {
 function user_edit_cancel_submit($form, &$form_state) {
   $destination = array();
   if (isset($_GET['destination'])) {
-    $destination = drupal_get_destination();
+    $destination = get_destination();
     unset($_GET['destination']);
   }
   // Note: We redirect from user/uid/edit to user/uid/cancel to make the tabs disappear.
@@ -405,7 +406,7 @@ function user_cancel_confirm_form_submit($form, &$form_state) {
     );
     $account = user_save($account, $edit);
     _user_mail_notify('cancel_confirm', $account);
-    drupal_set_message(t('A confirmation request to cancel your account has been sent to your e-mail address.'));
+    set_message(t('A confirmation request to cancel your account has been sent to your e-mail address.'));
     watchdog('user', 'Sent account cancellation request to %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
 
     $form_state['redirect'] = "user/$account->uid";
@@ -446,7 +447,7 @@ function user_cancel_methods() {
     ),
   );
   // Allow modules to customize account cancellation methods.
-  drupal_alter('user_cancel_methods', $methods);
+  alter('user_cancel_methods', $methods);
 
   // Turn all methods into real form elements.
   $default_method = variable_get('user_cancel_method', 'user_cancel_block');
@@ -488,11 +489,11 @@ function user_cancel_confirm($account, $timestamp = 0, $hashed_pass = '') {
       batch_process('');
     }
     else {
-      drupal_set_message(t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'));
-      drupal_goto("user/$account->uid/cancel");
+      set_message(t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'));
+      redirect("user/$account->uid/cancel");
     }
   }
-  drupal_access_denied();
+  access_denied();
 }
 
 /**
@@ -508,6 +509,6 @@ function user_page() {
     return menu_execute_active_handler(NULL, FALSE);
   }
   else {
-    return drupal_get_form('user_login');
+    return get_form('user_login');
   }
 }
diff --git a/core/modules/user/user.test b/core/modules/user/user.test
index 367bf82..133d6dd 100644
--- a/core/modules/user/user.test
+++ b/core/modules/user/user.test
@@ -1,11 +1,12 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
  * Tests for user.module.
  */
 
-class UserRegistrationTestCase extends DrupalWebTestCase {
+class UserRegistrationTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'User registration',
@@ -257,7 +258,7 @@ class UserRegistrationTestCase extends DrupalWebTestCase {
   }
 }
 
-class UserValidationTestCase extends DrupalWebTestCase {
+class UserValidationTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Username/e-mail validation',
@@ -311,7 +312,7 @@ class UserValidationTestCase extends DrupalWebTestCase {
 /**
  * Functional tests for user logins, including rate limiting of login attempts.
  */
-class UserLoginTestCase extends DrupalWebTestCase {
+class UserLoginTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'User login',
@@ -400,9 +401,9 @@ class UserLoginTestCase extends DrupalWebTestCase {
    */
   function testPasswordRehashOnLogin() {
     // Load password hashing API.
-    require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'core/includes/password.inc');
-    // Set initial $count_log2 to the default, DRUPAL_HASH_COUNT.
-    variable_set('password_count_log2', DRUPAL_HASH_COUNT);
+    require_once ROOT . '/' . variable_get('password_inc', 'core/includes/password.inc');
+    // Set initial $count_log2 to the default, HASH_COUNT.
+    variable_set('password_count_log2', HASH_COUNT);
     // Create a new user and authenticate.
     $account = $this->drupalCreateUser(array());
     $password = $account->pass_raw;
@@ -410,14 +411,14 @@ class UserLoginTestCase extends DrupalWebTestCase {
     $this->drupalLogout();
     // Load the stored user. The password hash should reflect $count_log2.
     $account = user_load($account->uid);
-    $this->assertIdentical(_password_get_count_log2($account->pass), DRUPAL_HASH_COUNT);
+    $this->assertIdentical(_password_get_count_log2($account->pass), HASH_COUNT);
     // Change $count_log2 and log in again.
-    variable_set('password_count_log2', DRUPAL_HASH_COUNT + 1);
+    variable_set('password_count_log2', HASH_COUNT + 1);
     $account->pass_raw = $password;
     $this->drupalLogin($account);
     // Load the stored user, which should have a different password hash now.
     $account = user_load($account->uid, TRUE);
-    $this->assertIdentical(_password_get_count_log2($account->pass), DRUPAL_HASH_COUNT + 1);
+    $this->assertIdentical(_password_get_count_log2($account->pass), HASH_COUNT + 1);
   }
 
   /**
@@ -454,7 +455,7 @@ class UserLoginTestCase extends DrupalWebTestCase {
 /**
  * Test cancelling a user.
  */
-class UserCancelTestCase extends DrupalWebTestCase {
+class UserCancelTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Cancel account',
@@ -507,7 +508,7 @@ class UserCancelTestCase extends DrupalWebTestCase {
   function testUserCancelUid1() {
     // Update uid 1's name and password to we know it.
     $password = user_password();
-    require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'core/includes/password.inc');
+    require_once ROOT . '/' . variable_get('password_inc', 'core/includes/password.inc');
     $account = array(
       'name' => 'user1',
       'pass' => user_hash_password(trim($password)),
@@ -849,7 +850,7 @@ class UserCancelTestCase extends DrupalWebTestCase {
   }
 }
 
-class UserPictureTestCase extends DrupalWebTestCase {
+class UserPictureTestCase extends WebTestCase {
   protected $user;
   protected $_directory_test;
 
@@ -1091,7 +1092,7 @@ class UserPictureTestCase extends DrupalWebTestCase {
 }
 
 
-class UserPermissionsTestCase extends DrupalWebTestCase {
+class UserPermissionsTestCase extends WebTestCase {
   protected $admin_user;
   protected $rid;
 
@@ -1128,8 +1129,8 @@ class UserPermissionsTestCase extends DrupalWebTestCase {
     $edit[$rid . '[administer nodes]'] = TRUE;
     $this->drupalPost('admin/people/permissions', $edit, t('Save permissions'));
     $this->assertText(t('The changes have been saved.'), t('Successful save message displayed.'));
-    drupal_static_reset('user_access');
-    drupal_static_reset('user_role_permissions');
+    drupal_static_reset('Drupal\user_access');
+    drupal_static_reset('Drupal\user_role_permissions');
     $this->assertTrue(user_access('administer nodes', $account), t('User now has "administer nodes" permission.'));
 
     // Remove a permission.
@@ -1138,8 +1139,8 @@ class UserPermissionsTestCase extends DrupalWebTestCase {
     $edit[$rid . '[access user profiles]'] = FALSE;
     $this->drupalPost('admin/people/permissions', $edit, t('Save permissions'));
     $this->assertText(t('The changes have been saved.'), t('Successful save message displayed.'));
-    drupal_static_reset('user_access');
-    drupal_static_reset('user_role_permissions');
+    drupal_static_reset('Drupal\user_access');
+    drupal_static_reset('Drupal\user_role_permissions');
     $this->assertFalse(user_access('access user profiles', $account), t('User no longer has "access user profiles" permission.'));
   }
 
@@ -1189,7 +1190,7 @@ class UserPermissionsTestCase extends DrupalWebTestCase {
   }
 }
 
-class UserAdminTestCase extends DrupalWebTestCase {
+class UserAdminTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'User administration',
@@ -1274,7 +1275,7 @@ class UserAdminTestCase extends DrupalWebTestCase {
 /**
  * Tests for user-configurable time zones.
  */
-class UserTimeZoneFunctionalTest extends DrupalWebTestCase {
+class UserTimeZoneFunctionalTest extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'User time zones',
@@ -1334,7 +1335,7 @@ class UserTimeZoneFunctionalTest extends DrupalWebTestCase {
 /**
  * Test user autocompletion.
  */
-class UserAutocompleteTestCase extends DrupalWebTestCase {
+class UserAutocompleteTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'User autocompletion',
@@ -1375,7 +1376,7 @@ class UserAutocompleteTestCase extends DrupalWebTestCase {
 /**
  * Test user-links in secondary menu.
  */
-class UserAccountLinksUnitTests extends DrupalWebTestCase {
+class UserAccountLinksUnitTests extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'User account links',
@@ -1424,7 +1425,7 @@ class UserAccountLinksUnitTests extends DrupalWebTestCase {
 /**
  * Test user blocks.
  */
-class UserBlocksUnitTests extends DrupalWebTestCase {
+class UserBlocksUnitTests extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'User blocks',
@@ -1499,7 +1500,7 @@ class UserBlocksUnitTests extends DrupalWebTestCase {
   private function insertSession(array $fields = array()) {
     $fields += array(
       'uid' => 0,
-      'sid' => drupal_hash_base64(uniqid(mt_rand(), TRUE)),
+      'sid' => hash_base64(uniqid(mt_rand(), TRUE)),
       'timestamp' => REQUEST_TIME,
     );
     db_insert('sessions')
@@ -1512,7 +1513,7 @@ class UserBlocksUnitTests extends DrupalWebTestCase {
 /**
  * Test case to test user_save() behaviour.
  */
-class UserSaveTestCase extends DrupalWebTestCase {
+class UserSaveTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1540,7 +1541,7 @@ class UserSaveTestCase extends DrupalWebTestCase {
       'pass' => user_password(),
       'status' => 1,
     );
-    $user_by_return = user_save(drupal_anonymous_user(), $user);
+    $user_by_return = user_save(anonymous_user(), $user);
     $this->assertTrue($user_by_return, t('Loading user by return of user_save().'));
 
     // Test if created user exists.
@@ -1555,7 +1556,7 @@ class UserSaveTestCase extends DrupalWebTestCase {
 /**
  * Test the create user administration page.
  */
-class UserCreateTestCase extends DrupalWebTestCase {
+class UserCreateTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1601,7 +1602,7 @@ class UserCreateTestCase extends DrupalWebTestCase {
 /**
  * Test case to test user_save() behaviour.
  */
-class UserEditTestCase extends DrupalWebTestCase {
+class UserEditTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1677,7 +1678,7 @@ class UserEditTestCase extends DrupalWebTestCase {
 /**
  * Test case for user signatures.
  */
-class UserSignatureTestCase extends DrupalWebTestCase {
+class UserSignatureTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'User signatures',
@@ -1761,7 +1762,7 @@ class UserSignatureTestCase extends DrupalWebTestCase {
 /*
  * Test that a user, having editing their own account, can still log in.
  */
-class UserEditedOwnAccountTestCase extends DrupalWebTestCase {
+class UserEditedOwnAccountTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1797,7 +1798,7 @@ class UserEditedOwnAccountTestCase extends DrupalWebTestCase {
 /**
  * Test case to test adding, editing and deleting roles.
  */
-class UserRoleAdminTestCase extends DrupalWebTestCase {
+class UserRoleAdminTestCase extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1850,9 +1851,9 @@ class UserRoleAdminTestCase extends DrupalWebTestCase {
 
     // Make sure that the system-defined roles cannot be edited via the user
     // interface.
-    $this->drupalGet('admin/people/permissions/roles/edit/' . DRUPAL_ANONYMOUS_RID);
+    $this->drupalGet('admin/people/permissions/roles/edit/' . ANONYMOUS_RID);
     $this->assertResponse(403, t('Access denied when trying to edit the built-in anonymous role.'));
-    $this->drupalGet('admin/people/permissions/roles/edit/' . DRUPAL_AUTHENTICATED_RID);
+    $this->drupalGet('admin/people/permissions/roles/edit/' . AUTHENTICATED_RID);
     $this->assertResponse(403, t('Access denied when trying to edit the built-in authenticated role.'));
   }
 
@@ -1882,7 +1883,7 @@ class UserRoleAdminTestCase extends DrupalWebTestCase {
 /**
  * Test user token replacement in strings.
  */
-class UserTokenReplaceTestCase extends DrupalWebTestCase {
+class UserTokenReplaceTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'User token replacement',
@@ -1947,7 +1948,7 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase {
 /**
  * Test user search.
  */
-class UserUserSearchTestCase extends DrupalWebTestCase {
+class UserUserSearchTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'User search',
@@ -1979,7 +1980,7 @@ class UserUserSearchTestCase extends DrupalWebTestCase {
 /**
  * Test role assignment.
  */
-class UserRolesAssignmentTestCase extends DrupalWebTestCase {
+class UserRolesAssignmentTestCase extends WebTestCase {
   protected $admin_user;
 
   public static function getInfo() {
@@ -2069,7 +2070,7 @@ class UserRolesAssignmentTestCase extends DrupalWebTestCase {
 /**
  * Unit test for authmap assignment.
  */
-class UserAuthmapAssignmentTestCase extends DrupalWebTestCase {
+class UserAuthmapAssignmentTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => t('Authmap assignment'),
@@ -2128,7 +2129,7 @@ class UserAuthmapAssignmentTestCase extends DrupalWebTestCase {
 /**
  * Tests user_validate_current_pass on a custom form.
  */
-class UserValidateCurrentPassCustomForm extends DrupalWebTestCase {
+class UserValidateCurrentPassCustomForm extends WebTestCase {
 
   public static function getInfo() {
     return array(
@@ -2173,7 +2174,7 @@ class UserValidateCurrentPassCustomForm extends DrupalWebTestCase {
 /**
  * Test user entity callbacks.
  */
-class UserEntityCallbacksTestCase extends DrupalWebTestCase {
+class UserEntityCallbacksTestCase extends WebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'User entity callback tests',
@@ -2186,7 +2187,7 @@ class UserEntityCallbacksTestCase extends DrupalWebTestCase {
     parent::setUp('user');
 
     $this->account = $this->drupalCreateUser();
-    $this->anonymous = drupal_anonymous_user();
+    $this->anonymous = anonymous_user();
   }
 
   /**
diff --git a/core/modules/user/user.tokens.inc b/core/modules/user/user.tokens.inc
index 76ec4a2..7cb14ad 100644
--- a/core/modules/user/user.tokens.inc
+++ b/core/modules/user/user.tokens.inc
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/scripts/dump-database-d7.sh b/core/scripts/dump-database-d7.sh
index f78f998..e925d46 100644
--- a/core/scripts/dump-database-d7.sh
+++ b/core/scripts/dump-database-d7.sh
@@ -13,7 +13,7 @@
  */
 
 // Define default settings.
-define('DRUPAL_ROOT', getcwd());
+define('ROOT', getcwd());
 $cmd = 'index.php';
 $_SERVER['HTTP_HOST']       = 'default';
 $_SERVER['REMOTE_ADDR']     = '127.0.0.1';
@@ -25,7 +25,7 @@ $_SERVER['HTTP_USER_AGENT'] = 'console';
 
 // Bootstrap Drupal.
 include_once './includes/bootstrap.inc';
-drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+bootstrap(BOOTSTRAP_FULL);
 
 // Include the utility drupal_var_export() function.
 include_once dirname(__FILE__) . '/../includes/utility.inc';
@@ -50,7 +50,7 @@ foreach (module_list() as $module) {
 $output .= " */\n\n";
 
 // Get the current schema, order it by table name.
-$schema = drupal_get_schema();
+$schema = get_schema();
 ksort($schema);
 
 // Export all the tables in the schema.
diff --git a/core/scripts/generate-d7-content.sh b/core/scripts/generate-d7-content.sh
index e65c099..7d75633 100644
--- a/core/scripts/generate-d7-content.sh
+++ b/core/scripts/generate-d7-content.sh
@@ -14,7 +14,7 @@
 
 // Define settings.
 $cmd = 'index.php';
-define('DRUPAL_ROOT', getcwd());
+define('ROOT', getcwd());
 $_SERVER['HTTP_HOST']       = 'default';
 $_SERVER['PHP_SELF']        = '/index.php';
 $_SERVER['REMOTE_ADDR']     = '127.0.0.1';
@@ -27,10 +27,10 @@ $modules_to_enable          = array('path', 'poll', 'taxonomy');
 
 // Bootstrap Drupal.
 include_once './includes/bootstrap.inc';
-drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+bootstrap(BOOTSTRAP_FULL);
 
 // Enable requested modules
-require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
+require_once ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
 include_once './modules/system/system.admin.inc';
 $form = system_modules();
 foreach ($modules_to_enable as $module) {
@@ -41,7 +41,7 @@ system_modules_submit(NULL, $form_state);
 unset($form_state);
 
 // Run cron after installing
-drupal_cron_run();
+cron_run();
 
 // Create six users
 $query = db_insert('users')->fields(array('uid', 'name', 'pass', 'mail', 'status', 'created', 'access'));
@@ -249,14 +249,14 @@ for ($i = 0; $i < 12; $i++) {
   $choices = array_keys($node->choice);
   $original_user = $GLOBALS['user'];
   for ($v = 0; $v < ($i % 4); $v++) {
-    drupal_static_reset('ip_address');
+    drupal_static_reset('Drupal\ip_address');
     $_SERVER['REMOTE_ADDR'] = "127.0.$v.1";
-    $GLOBALS['user'] = drupal_anonymous_user();// We should have already allowed anon to vote.
+    $GLOBALS['user'] = anonymous_user();// We should have already allowed anon to vote.
     $c = $v % $nbchoices;
     $form_state = array();
     $form_state['values']['choice'] = $choices[$c];
     $form_state['values']['op'] = t('Vote');
-    drupal_form_submit('poll_view_voting', $form_state, $node);
+    form_submit('poll_view_voting', $form_state, $node);
   }
 }
 
diff --git a/core/scripts/password-hash.sh b/core/scripts/password-hash.sh
index 8109af4..1d94f76 100755
--- a/core/scripts/password-hash.sh
+++ b/core/scripts/password-hash.sh
@@ -1,5 +1,6 @@
 #!/usr/bin/php
 <?php
+namespace drupal;
 
 /**
  * Drupal hash script - to generate a hash from a plaintext password
@@ -79,10 +80,10 @@ while ($param = array_shift($_SERVER['argv'])) {
 }
 
 chdir('..');
-define('DRUPAL_ROOT', getcwd());
+define('ROOT', getcwd());
 
-include_once DRUPAL_ROOT . '/core/includes/password.inc';
-include_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
+include_once ROOT . '/core/includes/password.inc';
+include_once ROOT . '/core/includes/bootstrap.inc';
 
 foreach ($passwords as $password) {
   print("\npassword: $password \t\thash: ". user_hash_password($password) ."\n");
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index 993df74..921623d 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 /**
  * @file
  * This script runs Drupal tests from command line.
@@ -27,7 +29,7 @@ else {
 }
 
 // Bootstrap to perform initial validation or other operations.
-drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+bootstrap(BOOTSTRAP_FULL);
 if (!module_exists('simpletest')) {
   simpletest_script_print_error("The simpletest module must be enabled before this script can run.");
   exit;
@@ -39,7 +41,7 @@ if ($args['clean']) {
   echo "\nEnvironment cleaned.\n";
 
   // Get the status messages and print them.
-  $messages = array_pop(drupal_get_messages('status'));
+  $messages = array_pop(get_messages('status'));
   foreach ($messages as $text) {
     echo " - " . $text . "\n";
   }
@@ -301,8 +303,8 @@ function simpletest_script_init($server_software) {
   }
 
   chdir(realpath(__DIR__ . '/../..'));
-  define('DRUPAL_ROOT', getcwd());
-  require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
+  define('ROOT', getcwd());
+  require_once ROOT . '/core/includes/bootstrap.inc';
 }
 
 /**
@@ -361,7 +363,7 @@ function simpletest_script_execute_batch($test_id, $test_classes) {
 function simpletest_script_run_one_test($test_id, $test_class) {
   try {
     // Bootstrap Drupal.
-    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+    bootstrap(BOOTSTRAP_FULL);
 
     $test = new $test_class($test_id);
     $test->run();
diff --git a/core/themes/bartik/color/color.inc b/core/themes/bartik/color/color.inc
index b4c813d..953dce1 100644
--- a/core/themes/bartik/color/color.inc
+++ b/core/themes/bartik/color/color.inc
@@ -1,7 +1,8 @@
 <?php
+namespace Drupal;
 
 // Put the logo path into JavaScript for the live preview.
-drupal_add_js(array('color' => array('logo' => theme_get_setting('logo', 'bartik'))), 'setting');
+add_js(array('color' => array('logo' => theme_get_setting('logo', 'bartik'))), 'setting');
 
 $info = array(
   // Available colors and color labels used in theme.
diff --git a/core/themes/bartik/template.php b/core/themes/bartik/template.php
index 8d2b8c4..7abf8cb 100644
--- a/core/themes/bartik/template.php
+++ b/core/themes/bartik/template.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Add body classes if certain regions have content.
@@ -22,7 +23,7 @@ function bartik_preprocess_html(&$variables) {
   }
 
   // Add conditional stylesheets for IE
-  drupal_add_css(path_to_theme() . '/css/ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
+  add_css(path_to_theme() . '/css/ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
 }
 
 /**
@@ -79,7 +80,7 @@ function bartik_preprocess_maintenance_page(&$variables) {
   if (!$variables['db_is_active']) {
     unset($variables['site_name']);
   }
-  drupal_add_css(drupal_get_path('theme', 'bartik') . '/css/maintenance-page.css');
+  add_css(get_path('theme', 'bartik') . '/css/maintenance-page.css');
 }
 
 /**
diff --git a/core/themes/bartik/templates/comment-wrapper.tpl.php b/core/themes/bartik/templates/comment-wrapper.tpl.php
index 864dc41..563f8ea 100644
--- a/core/themes/bartik/templates/comment-wrapper.tpl.php
+++ b/core/themes/bartik/templates/comment-wrapper.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/themes/bartik/templates/comment.tpl.php b/core/themes/bartik/templates/comment.tpl.php
index 553fb53..439a7cd 100644
--- a/core/themes/bartik/templates/comment.tpl.php
+++ b/core/themes/bartik/templates/comment.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/themes/bartik/templates/maintenance-page.tpl.php b/core/themes/bartik/templates/maintenance-page.tpl.php
index f2b998e..9a6ae54 100644
--- a/core/themes/bartik/templates/maintenance-page.tpl.php
+++ b/core/themes/bartik/templates/maintenance-page.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/themes/bartik/templates/node.tpl.php b/core/themes/bartik/templates/node.tpl.php
index 234b899..93fc6c5 100644
--- a/core/themes/bartik/templates/node.tpl.php
+++ b/core/themes/bartik/templates/node.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/themes/bartik/templates/page.tpl.php b/core/themes/bartik/templates/page.tpl.php
index 44e9cea..125e2b9 100644
--- a/core/themes/bartik/templates/page.tpl.php
+++ b/core/themes/bartik/templates/page.tpl.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
diff --git a/core/themes/engines/phptemplate/phptemplate.engine b/core/themes/engines/phptemplate/phptemplate.engine
index d293b85..eea22b1 100644
--- a/core/themes/engines/phptemplate/phptemplate.engine
+++ b/core/themes/engines/phptemplate/phptemplate.engine
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -11,7 +12,7 @@
 function phptemplate_init($template) {
   $file = dirname($template->filename) . '/template.php';
   if (file_exists($file)) {
-    include_once DRUPAL_ROOT . '/' . $file;
+    include_once ROOT . '/' . $file;
   }
 }
 
@@ -19,7 +20,7 @@ function phptemplate_init($template) {
  * Implements hook_theme().
  */
 function phptemplate_theme($existing, $type, $theme, $path) {
-  $templates = drupal_find_theme_functions($existing, array($theme));
-  $templates += drupal_find_theme_templates($existing, '.tpl.php', $path);
+  $templates = find_theme_functions($existing, array($theme));
+  $templates += find_theme_templates($existing, '.tpl.php', $path);
   return $templates;
 }
diff --git a/core/themes/seven/maintenance-page.tpl.php b/core/themes/seven/maintenance-page.tpl.php
index 85c9f08..3d61798 100644
--- a/core/themes/seven/maintenance-page.tpl.php
+++ b/core/themes/seven/maintenance-page.tpl.php
@@ -1,3 +1,6 @@
+<?php
+namespace drupal;
+?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->langcode ?>" lang="<?php print $language->langcode ?>" dir="<?php print $language->dir ?>">
diff --git a/core/themes/seven/page.tpl.php b/core/themes/seven/page.tpl.php
index 4d40cf8..cf6181f 100644
--- a/core/themes/seven/page.tpl.php
+++ b/core/themes/seven/page.tpl.php
@@ -1,3 +1,6 @@
+<?php
+namespace drupal;
+?>
 
   <div id="branding" class="clearfix">
     <?php print $breadcrumb; ?>
diff --git a/core/themes/seven/template.php b/core/themes/seven/template.php
index 145ad22..f390c1e 100644
--- a/core/themes/seven/template.php
+++ b/core/themes/seven/template.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Override or insert variables into the maintenance page template.
@@ -17,7 +18,7 @@ function seven_preprocess_maintenance_page(&$vars) {
  */
 function seven_preprocess_html(&$vars) {
   // Add conditional CSS for IE8 and below.
-  drupal_add_css(path_to_theme() . '/ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE), 'weight' => 999, 'preprocess' => FALSE));
+  add_css(path_to_theme() . '/ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE), 'weight' => 999, 'preprocess' => FALSE));
 }
 
 /**
@@ -84,7 +85,7 @@ function seven_admin_block_content($variables) {
  */
 function seven_tablesort_indicator($variables) {
   $style = $variables['style'];
-  $theme_path = drupal_get_path('theme', 'seven');
+  $theme_path = get_path('theme', 'seven');
   if ($style == 'asc') {
     return theme('image', array('uri' => $theme_path . '/images/arrow-asc.png', 'alt' => t('sort ascending'), 'width' => 13, 'height' => 13, 'title' => t('sort ascending')));
   }
@@ -99,13 +100,13 @@ function seven_tablesort_indicator($variables) {
 function seven_css_alter(&$css) {
   // Use Seven's vertical tabs style instead of the default one.
   if (isset($css['core/misc/vertical-tabs.css'])) {
-    $css['core/misc/vertical-tabs.css']['data'] = drupal_get_path('theme', 'seven') . '/vertical-tabs.css';
+    $css['core/misc/vertical-tabs.css']['data'] = get_path('theme', 'seven') . '/vertical-tabs.css';
   }
   if (isset($css['core/misc/vertical-tabs-rtl.css'])) {
-    $css['core/misc/vertical-tabs-rtl.css']['data'] = drupal_get_path('theme', 'seven') . '/vertical-tabs-rtl.css';
+    $css['core/misc/vertical-tabs-rtl.css']['data'] = get_path('theme', 'seven') . '/vertical-tabs-rtl.css';
   }
   // Use Seven's jQuery UI theme style instead of the default one.
   if (isset($css['core/misc/ui/jquery.ui.theme.css'])) {
-    $css['core/misc/ui/jquery.ui.theme.css']['data'] = drupal_get_path('theme', 'seven') . '/jquery.ui.theme.css';
+    $css['core/misc/ui/jquery.ui.theme.css']['data'] = get_path('theme', 'seven') . '/jquery.ui.theme.css';
   }
 }
diff --git a/core/update.php b/core/update.php
index dd338a2..737c9cc 100644
--- a/core/update.php
+++ b/core/update.php
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use Exception;
 
 /**
  * @file
@@ -20,7 +22,7 @@ chdir('..');
 /**
  * Root directory of Drupal installation.
  */
-define('DRUPAL_ROOT', getcwd());
+define('ROOT', getcwd());
 
 /**
  * Global flag indicating that update.php is being run.
@@ -28,11 +30,11 @@ define('DRUPAL_ROOT', getcwd());
  * When this flag is set, various operations do not take place, such as invoking
  * hook_init() and hook_exit(), css/js preprocessing, and translation.
  */
-const MAINTENANCE_MODE = 'update';
+define('MAINTENANCE_MODE', 'update');
 
 function update_selection_page() {
-  drupal_set_title('Drupal database update');
-  $elements = drupal_get_form('update_script_selection_form');
+  set_title('Drupal database update');
+  $elements = get_form('update_script_selection_form');
   $output = drupal_render($elements);
 
   update_task_list('select');
@@ -102,18 +104,18 @@ function update_script_selection_form($form, &$form_state) {
 
   // Warn the user if any updates were incompatible.
   if ($incompatible_updates_exist) {
-    drupal_set_message('Some of the pending updates cannot be applied because their dependencies were not met.', 'warning');
+    set_message('Some of the pending updates cannot be applied because their dependencies were not met.', 'warning');
   }
 
   if (empty($count)) {
-    drupal_set_message(t('No pending updates.'));
+    set_message(t('No pending updates.'));
     unset($form);
     $form['links'] = array(
       '#markup' => theme('item_list', array('items' => update_helpful_links())),
     );
 
     // No updates to run, so caches won't get flushed later.  Clear them now.
-    drupal_flush_all_caches();
+    flush_all_caches();
   }
   else {
     $form['help'] = array(
@@ -153,7 +155,7 @@ function update_helpful_links() {
 }
 
 function update_results_page() {
-  drupal_set_title('Drupal database update');
+  set_title('Drupal database update');
   $links = update_helpful_links();
 
   update_task_list();
@@ -234,15 +236,15 @@ function update_results_page() {
 
 function update_info_page() {
   // Change query-strings on css/js files to enforce reload for all users.
-  _drupal_flush_css_js();
+  _flush_css_js();
   // Flush the cache of all data for the update status module.
   if (db_table_exists('cache_update')) {
     cache('update')->flush();
   }
 
   update_task_list('info');
-  drupal_set_title('Drupal database update');
-  $token = drupal_get_token('update');
+  set_title('Drupal database update');
+  $token = get_token('update');
   $output = '<p>Use this utility to update your database whenever a new release of Drupal or a module is installed.</p><p>For more detailed information, see the <a href="http://drupal.org/upgrade">upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.</p>';
   $output .= "<ol>\n";
   $output .= "<li><strong>Back up your database</strong>. This process will change your database values and in case of emergency you may need to revert to a backup.</li>\n";
@@ -251,16 +253,16 @@ function update_info_page() {
   $output .= "<li>Install your new files in the appropriate location, as described in the handbook.</li>\n";
   $output .= "</ol>\n";
   $output .= "<p>When you have performed the steps above, you may proceed.</p>\n";
-  $form_action = check_url(drupal_current_script_url(array('op' => 'selection', 'token' => $token)));
+  $form_action = check_url(current_script_url(array('op' => 'selection', 'token' => $token)));
   $output .= '<form method="post" action="' . $form_action . '"><p><input type="submit" value="Continue" class="form-submit" /></p></form>';
   $output .= "\n";
   return $output;
 }
 
 function update_access_denied_page() {
-  drupal_add_http_header('Status', '403 Forbidden');
+  add_http_header('Status', '403 Forbidden');
   watchdog('access denied', 'update.php', NULL, WATCHDOG_WARNING);
-  drupal_set_title('Access denied');
+  set_title('Access denied');
   return '<p>Access denied. You are not authorized to access this page. Log in using either an account with the <em>administer software updates</em> permission or the site maintenance account (the account you created during installation). If you cannot log in, you will have to edit <code>settings.php</code> to bypass this access check. To do this:</p>
 <ol>
  <li>With a text editor find the settings.php file on your system. From the main Drupal directory that you installed all the files into, go to <code>sites/your_site_name</code> if such directory exists, or else to <code>sites/default</code> which applies otherwise.</li>
@@ -286,7 +288,7 @@ function update_access_allowed() {
   // Calls to user_access() might fail during the Drupal 6 to 7 update process,
   // so we fall back on requiring that the user be logged in as user #1.
   try {
-    require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'user') . '/user.module';
+    require_once ROOT . '/' . get_path('module', 'user') . '/user.module';
     return user_access('administer software updates');
   }
   catch (Exception $e) {
@@ -307,7 +309,7 @@ function update_task_list($active = NULL) {
     'finished' => 'Review log',
   );
 
-  drupal_add_region_content('sidebar_first', theme('task_list', array('items' => $tasks, 'active' => $active)));
+  add_region_content('sidebar_first', theme('task_list', array('items' => $tasks, 'active' => $active)));
 }
 
 /**
@@ -334,15 +336,15 @@ function update_check_requirements($skip_warnings = FALSE) {
   // Check requirements of all loaded modules.
   $requirements = module_invoke_all('requirements', 'update');
   $requirements += update_extra_requirements();
-  $severity = drupal_requirements_severity($requirements);
+  $severity = requirements_severity($requirements);
 
   // If there are errors, always display them. If there are only warnings, skip
   // them if the caller has indicated they should be skipped.
   if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING && !$skip_warnings)) {
     update_task_list('requirements');
-    drupal_set_title('Requirements problem');
+    set_title('Requirements problem');
     $status_report = theme('status_report', array('requirements' => $requirements));
-    $status_report .= 'Check the messages and <a href="' . check_url(drupal_requirements_url($severity)) . '">try again</a>.';
+    $status_report .= 'Check the messages and <a href="' . check_url(requirements_url($severity)) . '">try again</a>.';
     print theme('update_page', array('content' => $status_report));
     exit();
   }
@@ -354,60 +356,60 @@ ini_set('display_errors', FALSE);
 
 // We prepare a minimal bootstrap for the update requirements check to avoid
 // reaching the PHP memory limit.
-require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
-require_once DRUPAL_ROOT . '/core/includes/update.inc';
-require_once DRUPAL_ROOT . '/core/includes/common.inc';
-require_once DRUPAL_ROOT . '/core/includes/file.inc';
-require_once DRUPAL_ROOT . '/core/includes/unicode.inc';
+require_once ROOT . '/core/includes/bootstrap.inc';
+require_once ROOT . '/core/includes/update.inc';
+require_once ROOT . '/core/includes/common.inc';
+require_once ROOT . '/core/includes/file.inc';
+require_once ROOT . '/core/includes/unicode.inc';
 update_prepare_d8_bootstrap();
 
 // Determine if the current user has access to run update.php.
-drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
+bootstrap(BOOTSTRAP_SESSION);
 
 // Only allow the requirements check to proceed if the current user has access
 // to run updates (since it may expose sensitive information about the site's
 // configuration).
 $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
 if (empty($op) && update_access_allowed()) {
-  require_once DRUPAL_ROOT . '/core/includes/install.inc';
-  require_once DRUPAL_ROOT . '/core/modules/system/system.install';
+  require_once ROOT . '/core/includes/install.inc';
+  require_once ROOT . '/core/modules/system/system.install';
 
   // Load module basics.
-  include_once DRUPAL_ROOT . '/core/includes/module.inc';
+  include_once ROOT . '/core/includes/module.inc';
   $module_list['system']['filename'] = 'core/modules/system/system.module';
   module_list(TRUE, FALSE, FALSE, $module_list);
-  drupal_load('module', 'system');
+  load('module', 'system');
 
   // Reset the module_implements() cache so that any new hook implementations
   // in updated code are picked up.
   module_implements_reset();
 
   // Set up $language, since the installer components require it.
-  drupal_language_initialize();
+  language_initialize();
 
   // Set up theme system for the maintenance page.
-  drupal_maintenance_theme();
+  maintenance_theme();
 
   // Check the update requirements for Drupal. Only report on errors at this
   // stage, since the real requirements check happens further down.
   update_check_requirements(TRUE);
 
   // Redirect to the update information page if all requirements were met.
-  install_goto('core/update.php?op=info');
+  install_redirect('core/update.php?op=info');
 }
 
 // update_fix_d8_requirements() needs to run before bootstrapping beyond path.
-// So bootstrap to DRUPAL_BOOTSTRAP_LANGUAGE then include unicode.inc.
+// So bootstrap to BOOTSTRAP_LANGUAGE then include unicode.inc.
 
-drupal_bootstrap(DRUPAL_BOOTSTRAP_LANGUAGE);
-include_once DRUPAL_ROOT . '/core/includes/unicode.inc';
+bootstrap(BOOTSTRAP_LANGUAGE);
+include_once ROOT . '/core/includes/unicode.inc';
 
 update_fix_d8_requirements();
 
 // Now proceed with a full bootstrap.
 
-drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
-drupal_maintenance_theme();
+bootstrap(BOOTSTRAP_FULL);
+maintenance_theme();
 
 // Turn error reporting back on. From now on, only fatal errors (which are
 // not passed through the error handler) will cause a message to be printed.
@@ -416,16 +418,16 @@ ini_set('display_errors', TRUE);
 // Only proceed with updates if the user is allowed to run them.
 if (update_access_allowed()) {
 
-  include_once DRUPAL_ROOT . '/core/includes/install.inc';
-  include_once DRUPAL_ROOT . '/core/includes/batch.inc';
-  drupal_load_updates();
+  include_once ROOT . '/core/includes/install.inc';
+  include_once ROOT . '/core/includes/batch.inc';
+  load_updates();
 
   update_fix_compatibility();
 
   // Check the update requirements for all modules. If there are warnings, but
   // no errors, skip reporting them if the user has provided a URL parameter
   // acknowledging the warnings and indicating a desire to continue anyway. See
-  // drupal_requirements_url().
+  // requirements_url().
   $skip_warnings = !empty($_GET['continue']);
   update_check_requirements($skip_warnings);
 
@@ -434,18 +436,18 @@ if (update_access_allowed()) {
     // update.php ops.
 
     case 'selection':
-      if (isset($_GET['token']) && $_GET['token'] == drupal_get_token('update')) {
+      if (isset($_GET['token']) && $_GET['token'] == get_token('update')) {
         $output = update_selection_page();
         break;
       }
 
     case 'Apply pending updates':
-      if (isset($_GET['token']) && $_GET['token'] == drupal_get_token('update')) {
+      if (isset($_GET['token']) && $_GET['token'] == get_token('update')) {
         // Generate absolute URLs for the batch processing (using $base_root),
         // since the batch API will pass them to url() which does not handle
         // update.php correctly by default.
-        $batch_url = $base_root . drupal_current_script_url();
-        $redirect_url = $base_root . drupal_current_script_url(array('op' => 'results'));
+        $batch_url = $base_root . current_script_url();
+        $redirect_url = $base_root . current_script_url(array('op' => 'results'));
         update_batch($_POST['start'], $redirect_url, $batch_url);
         break;
       }
diff --git a/core/xmlrpc.php b/core/xmlrpc.php
index 562aa81..4a686c4 100644
--- a/core/xmlrpc.php
+++ b/core/xmlrpc.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -11,11 +12,11 @@ chdir('..');
 /**
  * Root directory of Drupal installation.
  */
-define('DRUPAL_ROOT', getcwd());
+define('ROOT', getcwd());
 
-include_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
-drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
-include_once DRUPAL_ROOT . '/core/includes/xmlrpc.inc';
-include_once DRUPAL_ROOT . '/core/includes/xmlrpcs.inc';
+include_once ROOT . '/core/includes/bootstrap.inc';
+bootstrap(BOOTSTRAP_FULL);
+include_once ROOT . '/core/includes/xmlrpc.inc';
+include_once ROOT . '/core/includes/xmlrpcs.inc';
 
 xmlrpc_server(module_invoke_all('xmlrpc'));
diff --git a/index.php b/index.php
index b91fb1e..9d83fd6 100644
--- a/index.php
+++ b/index.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -14,8 +15,8 @@
 /**
  * Root directory of Drupal installation.
  */
-define('DRUPAL_ROOT', getcwd());
+define('ROOT', getcwd());
 
-require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
-drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+require_once ROOT . '/core/includes/bootstrap.inc';
+bootstrap(BOOTSTRAP_FULL);
 menu_execute_active_handler();
diff --git a/profiles/minimal/minimal.install b/profiles/minimal/minimal.install
index d5b85c5..92f10bd 100644
--- a/profiles/minimal/minimal.install
+++ b/profiles/minimal/minimal.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Implements hook_install().
@@ -79,6 +80,6 @@ function minimal_install() {
   variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
 
   // Enable default permissions for system roles.
-  user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content'));
-  user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content'));
+  user_role_grant_permissions(ANONYMOUS_RID, array('access content'));
+  user_role_grant_permissions(AUTHENTICATED_RID, array('access content'));
 }
diff --git a/profiles/standard/standard.install b/profiles/standard/standard.install
index e570c18..e974f61 100644
--- a/profiles/standard/standard.install
+++ b/profiles/standard/standard.install
@@ -1,4 +1,6 @@
 <?php
+namespace Drupal;
+use stdClass;
 
 /**
  * Implements hook_install().
@@ -398,8 +400,8 @@ function standard_install() {
 
   // Enable default permissions for system roles.
   $filtered_html_permission = filter_permission_name($filtered_html_format);
-  user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content', 'access comments', $filtered_html_permission));
-  user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content', 'access comments', 'post comments', 'skip comment approval', $filtered_html_permission));
+  user_role_grant_permissions(ANONYMOUS_RID, array('access content', 'access comments', $filtered_html_permission));
+  user_role_grant_permissions(AUTHENTICATED_RID, array('access content', 'access comments', 'post comments', 'skip comment approval', $filtered_html_permission));
 
   // Create a default role for site administrators, with all available permissions assigned.
   $admin_role = new stdClass();
diff --git a/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module b/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module
index b3d9bbc..66bf2d1 100644
--- a/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module
+++ b/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module
@@ -1 +1,2 @@
 <?php
+namespace Drupal;
diff --git a/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module b/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module
index b3d9bbc..66bf2d1 100644
--- a/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module
+++ b/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module
@@ -1 +1,2 @@
 <?php
+namespace Drupal;
diff --git a/profiles/testing/testing.install b/profiles/testing/testing.install
index 19092d4..c9c65a5 100644
--- a/profiles/testing/testing.install
+++ b/profiles/testing/testing.install
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * Implements hook_install().
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
index 360e556..59ba475 100755
--- a/sites/default/default.settings.php
+++ b/sites/default/default.settings.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
@@ -229,10 +230,10 @@ $update_free_access = FALSE;
  * with any backups of your Drupal files and database.
  *
  * Example:
- *   $drupal_hash_salt = file_get_contents('/home/example/salt.txt');
+ *   $hash_salt = file_get_contents('/home/example/salt.txt');
  *
  */
-$drupal_hash_salt = '';
+$hash_salt = '';
 
 /**
  * Base URL (optional).
@@ -262,7 +263,7 @@ $drupal_hash_salt = '';
  * To see what PHP settings are possible, including whether they can be set at
  * runtime (by using ini_set()), read the PHP documentation:
  * http://www.php.net/manual/en/ini.list.php
- * See drupal_initialize_variables() in includes/bootstrap.inc for required
+ * See settings_initialize() in includes/bootstrap.inc for required
  * runtime settings and the .htaccess file for non-runtime settings. Settings
  * defined there should not be duplicated here so as to avoid conflict issues.
  */
@@ -493,7 +494,7 @@ $conf['404_fast_html'] = '<html xmlns="http://www.w3.org/1999/xhtml"><head><titl
  *
  * To enable this functionality, remove the leading hash sign below.
  */
-# drupal_fast_404();
+# fast_404();
 
 /**
  * Authorized file system operations:
diff --git a/sites/example.sites.php b/sites/example.sites.php
index 08c1020..c661b5b 100644
--- a/sites/example.sites.php
+++ b/sites/example.sites.php
@@ -1,4 +1,5 @@
 <?php
+namespace Drupal;
 
 /**
  * @file
