Fixed tutorial design
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index f310cbf..902934b 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -27,6 +27,16 @@
       };
   }) if $self->mode eq 'production';
 
+  $self->hook(before_dispatch => sub {
+      my $c = shift;
+      my $h = $c->res->headers;
+      $h->header( 'Access-Control-Allow-Origin' => '*' );
+      $h->header( 'Access-Control-Allow-Methods' => 'GET, PUT, POST, DELETE, OPTIONS' );
+      $h->header( 'Access-Control-Max-Age' => 3600 );
+      $h->header( 'Access-Control-Allow-Headers' => 'Content-Type, Authorization, X-Requested-With' );
+    });
+
+
   # Add additional plugin path
   push(@{$self->plugins->namespaces}, __PACKAGE__ . '::Plugin');
 
diff --git a/lib/Kalamar/Controller/Search.pm b/lib/Kalamar/Controller/Search.pm
index d3cdfb3..f56ca77 100644
--- a/lib/Kalamar/Controller/Search.pm
+++ b/lib/Kalamar/Controller/Search.pm
@@ -61,9 +61,9 @@
   my $foundry = '*';
   my %query = (foundry => '*');
   if ($c->param('foundry')) {
-    $query{foundry} = $c->param('foundry');
+    $query{foundry} = scalar $c->param('foundry');
     if ($c->param('layer')) {
-      $query{layer} = $c->param('layer');
+      $query{layer} = scalar $c->param('layer');
     };
     if ($c->param('spans')) {
       $query{spans} = 'true';