diff --git a/app/controllers/api/accounts_controller.rb b/app/controllers/api/accounts_controller.rb
index 8c4da527019bb307e37744b14685c73d83029985..4a4431b2d5b73b5ee8e187b67e9f04dee67606b5 100644
--- a/app/controllers/api/accounts_controller.rb
+++ b/app/controllers/api/accounts_controller.rb
@@ -19,12 +19,7 @@ class Api::AccountsController < ApiController
   end
 
   def follow
-    if @account.local?
-      @follow = current_user.account.follow!(@account)
-    else
-      @follow = FollowService.new.(current_user.account, @account.acct)
-    end
-
+    @follow = FollowService.new.(current_user.account, @account.acct)
     render action: :show
   end
 
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 73de1838cfb1285202bd13fcf15a7b969c29f77b..90e923951e2a994a9a79b1c103b4166506dce8fa 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -7,8 +7,21 @@ class ApplicationController < ActionController::Base
 
   helper_method :current_account
 
+  rescue_from ActionController::RoutingError, with: :not_found
+  rescue_from ActiveRecord::RecordNotFound, with: :not_found
+
+  def raise_not_found
+    raise ActionController::RoutingError.new("No route matches #{params[:unmatched_route]}")
+  end
+
   protected
 
+  def not_found
+    respond_to do |format|
+      format.any { head 404 }
+    end
+  end
+
   def current_account
     current_user.try(:account)
   end
diff --git a/app/services/follow_remote_account_service.rb b/app/services/follow_remote_account_service.rb
index f056684201dab644d6a105bdf6ec4c07b188a758..c4330d7cf3b5732fa3c9e066b78f4d91314169c4 100644
--- a/app/services/follow_remote_account_service.rb
+++ b/app/services/follow_remote_account_service.rb
@@ -8,7 +8,7 @@ class FollowRemoteAccountService < BaseService
   def call(uri, subscribe = true)
     username, domain = uri.split('@')
 
-    return Account.find_local(username) if domain == Rails.configuration.x.local_domain
+    return Account.find_local(username) if domain == Rails.configuration.x.local_domain || domain.nil?
 
     account = Account.find_remote(username, domain)
 
diff --git a/app/services/follow_service.rb b/app/services/follow_service.rb
index 06bbfa8f08083f164f71c504394987b48cea4152..e4a4bfcd3420e1dd880878509929291921e93f36 100644
--- a/app/services/follow_service.rb
+++ b/app/services/follow_service.rb
@@ -8,7 +8,13 @@ class FollowService < BaseService
     return nil if target_account.nil?
 
     follow = source_account.follow!(target_account)
-    NotificationWorker.perform_async(follow.stream_entry.id, target_account.id)
+
+    if target_account.local?
+      NotificationMailer.follow(target_account, source_account).deliver_later
+    else
+      NotificationWorker.perform_async(follow.stream_entry.id, target_account.id)
+    end
+
     source_account.ping!(account_url(source_account, format: 'atom'), [Rails.configuration.x.hub_url])
     follow
   end
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 288256dcf2e66cc2b132b4c8b11326fa90a9cabc..d0ff03754ba770ffd2cb20543efa7b1f52cbab20 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -10,7 +10,7 @@ Rails.application.configure do
   config.eager_load = false
 
   # Show full error reports.
-  config.consider_all_requests_local= true
+  config.consider_all_requests_local = true
 
   # Enable/disable caching. By default caching is disabled.
   if Rails.root.join('tmp/caching-dev.txt').exist?
diff --git a/config/routes.rb b/config/routes.rb
index 9ad7a32e1bc2901a17863c336c88a70ee21e47ae..6201a4ee7227bd143f2f02c6dd1d3f44f6f8305a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -72,4 +72,6 @@ Rails.application.routes.draw do
   end
 
   root 'home#index'
+
+  match '*unmatched_route', via: :all, to: 'application#raise_not_found'
 end
diff --git a/spec/controllers/api/accounts_controller_spec.rb b/spec/controllers/api/accounts_controller_spec.rb
index d8b26f815a0b6b29449d9848a8905d6dd28afe33..91e62837cff0813299cbb2762922c6deb88ae52d 100644
--- a/spec/controllers/api/accounts_controller_spec.rb
+++ b/spec/controllers/api/accounts_controller_spec.rb
@@ -7,6 +7,7 @@ RSpec.describe Api::AccountsController, type: :controller do
   let(:token) { double acceptable?: true, resource_owner_id: user.id }
 
   before do
+    stub_request(:post, "https://pubsubhubbub.superfeedr.com/").to_return(:status => 200, :body => "", :headers => {})
     allow(controller).to receive(:doorkeeper_token) { token }
   end
 
@@ -39,7 +40,7 @@ RSpec.describe Api::AccountsController, type: :controller do
   end
 
   describe 'POST #follow' do
-    let(:other_account) { Fabricate(:account, username: 'bob') }
+    let(:other_account) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob')).account }
 
     before do
       post :follow, params: { id: other_account.id }
@@ -55,7 +56,7 @@ RSpec.describe Api::AccountsController, type: :controller do
   end
 
   describe 'POST #unfollow' do
-    let(:other_account) { Fabricate(:account, username: 'bob') }
+    let(:other_account) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob')).account }
 
     before do
       user.account.follow!(other_account)