diff --git a/dev/js/src/datepicker.js b/dev/js/src/datepicker.js
index 0fd47dd..8ae5267 100644
--- a/dev/js/src/datepicker.js
+++ b/dev/js/src/datepicker.js
@@ -7,6 +7,9 @@
 define(['util'], function () {
   "use strict";
 
+  KorAP._validDateMatchRE   = new RegExp("^[lg]?eq$");
+  KorAP._validDateRE        = new RegExp("^(?:\\d{4})(?:-\\d\\d(?:-\\d\\d)?)?$");
+
   /*
    * Localizations
    */
@@ -45,18 +48,18 @@
      */
     select : function (year, month, day) {
       if (arguments.length >= 1) {
-	this._selected = {'year' : year};
-	this._showYear = year;
-	if (arguments.length >= 2) {
-	  this._selected['month'] = month;
-	  this._showMonth = month;
-	  if (arguments.length >= 3) {
-	    this._selected['day'] = day;
-	    this._showDay = day;
-	  };
-	};
+        this._selected = {'year' : year};
+        this._showYear = year;
+        if (arguments.length >= 2) {
+          this._selected['month'] = month;
+          this._showMonth = month;
+          if (arguments.length >= 3) {
+            this._selected['day'] = day;
+            this._showDay = day;
+          };
+        };
 
-	return this;
+        return this;
       };
 
       return this._selected;
@@ -74,11 +77,11 @@
 
     store : function () {
       if (this._click !== undefined)
-	this._click(this._selected);
+        this._click(this._selected);
       else 
-	console.dir(this._selected);
+        console.dir(this._selected);
     },
-
+    
     /**
      * Set the action for clicking as a callback.
      * The callback will retrieve a an object with
@@ -103,18 +106,18 @@
       e.setAttribute('tabindex', 0);
       e.style.outline = 0;
       e.classList.add('datepicker');
-
+      
       var today = new Date();
 
       // Show year
       this._showYear = (year !== undefined) ? year :
-	(this._selected['year'] ? this._selected['year'] :
-	 today.getYear() + 1900);
+        (this._selected['year'] ? this._selected['year'] :
+         today.getYear() + 1900);
 
       // Show month
       this._showMonth = month ? month :
-	(this._selected['month'] ? this._selected['month'] :
-	 (today.getMonth() + 1));
+        (this._selected['month'] ? this._selected['month'] :
+         (today.getMonth() + 1));
 
       // Append all helpers
       this._element.appendChild(this._monthHelper());
@@ -134,25 +137,29 @@
       input.setAttribute('tabindex', 0);
 
       input.addEventListener(
-	'keyup',
-	function (e) {
-	  if (e.keyCode == 13) {
-	    if (this.fromString(input.value))
-	      this.store();
-
-	    e.halt();
-            return false;
-	  }
-	  else {
-	    if (this.fromString(input.value)) {
-	      this._updateYear();
-	      this._updateMonth();
-	      this._updateDay();
-	    };
-	  };
-	}.bind(this)
+        'keyup',
+        function (e) {
+          if (this.fromString(input.value)) {
+            this._updateYear();
+            this._updateMonth();
+            this._updateDay();
+          };
+        }.bind(this)
       );
 
+      input.addEventListener(
+        'keypress',
+        function (e) {
+          if (e.keyCode == 13) {
+            if (this.fromString(input.value))
+              this.store();
+
+            e.halt();
+            return false;
+          }
+        }.bind(this)
+      )
+
       return input;
     },
 
@@ -181,15 +188,15 @@
       var v = '';
       var s = this._selected;
       if (s['year']) {
-	v += s['year'];
-	if (s['month']) {
-	  v += '-';
-	  v += s['month'] < 10 ? '0' + s['month'] : s['month'];
-	  if (s['day']) {
-	    v += '-';
-	    v += s['day'] < 10 ? '0' + s['day'] : s['day'];
-	  };
-	};
+        v += s['year'];
+        if (s['month']) {
+          v += '-';
+          v += s['month'] < 10 ? '0' + s['month'] : s['month'];
+          if (s['day']) {
+            v += '-';
+            v += s['day'] < 10 ? '0' + s['day'] : s['day'];
+          };
+        };
       };
       return v;
     },
@@ -199,11 +206,11 @@
      */
     incrYear : function () {
       if (this._showYear < 9999) {
-	this._showYear++;
-	this._updateYear();
-	this._updateMonth();
-	this._updateDay();
-	return this;
+        this._showYear++;
+        this._updateYear();
+        this._updateMonth();
+        this._updateDay();
+        return this;
       };
       return;
     },
@@ -214,11 +221,11 @@
      */
     decrYear : function () {
       if (this._showYear > 0) {
-	this._showYear--;
-	this._updateYear();
-	this._updateMonth();
-	this._updateDay();
-	return this;
+        this._showYear--;
+        this._updateYear();
+        this._updateMonth();
+        this._updateDay();
+        return this;
       };
       return;
     },
@@ -230,12 +237,12 @@
     incrMonth : function () {
       this._showMonth++;
       if (this._showMonth > 12) {
-	this._showMonth = 1;
-	this.incrYear();
+        this._showMonth = 1;
+        this.incrYear();
       }
       else {
-	this._updateMonth();
-	this._updateDay();
+        this._updateMonth();
+        this._updateDay();
       };
       return this;
     },
@@ -247,12 +254,12 @@
     decrMonth : function () {
       this._showMonth--;
       if (this._showMonth < 1) {
-	this._showMonth = 12;
-	this.decrYear();
+        this._showMonth = 12;
+        this.decrYear();
       }
       else {
-	this._updateMonth();
-	this._updateDay();
+        this._updateMonth();
+        this._updateDay();
       };
 
       return this;
@@ -266,19 +273,19 @@
 
       // Decrement year
       year.appendChild(d.createElement('span'))
-	.onclick = this.decrYear.bind(this);
+        .onclick = this.decrYear.bind(this);
 
       this._yElement = year.appendChild(d.createElement('span'));
       this._yElement.appendChild(document.createTextNode(this._showYear));
 
       this._yElement.onclick = function () {
-	this.set(this._showYear);
+        this.set(this._showYear);
       }.bind(this);
       this._selectYear();
 
       // Increment year
       year.appendChild(d.createElement('span'))
-	.onclick = this.incrYear.bind(this);
+        .onclick = this.incrYear.bind(this);
 
       return year;
     },
@@ -293,9 +300,9 @@
     // Check if the viewed year is current
     _selectYear : function () {
       if (this._showYear === this.select()['year'])
-	this._yElement.classList.add('selected');
+        this._yElement.classList.add('selected');
       else
-	this._yElement.classList.remove('selected');
+        this._yElement.classList.remove('selected');
     },
 
 
@@ -306,21 +313,21 @@
 
       // Decrement month
       month.appendChild(d.createElement('span'))
-	.onclick = this.decrMonth.bind(this);
+        .onclick = this.decrMonth.bind(this);
       
       this._mElement = month.appendChild(d.createElement('span'));
       this._mElement.appendChild(
-	document.createTextNode(loc.MONTH[this._showMonth-1])
+        document.createTextNode(loc.MONTH[this._showMonth-1])
       );
       this._mElement.onclick = function () {
-	this.set(this._showYear, this._showMonth);
+        this.set(this._showYear, this._showMonth);
       }.bind(this);
 
       this._selectMonth();
       
       // Increment month
       month.appendChild(d.createElement('span'))
-	.onclick = this.incrMonth.bind(this);
+        .onclick = this.incrMonth.bind(this);
 
       return month;
     },
@@ -328,7 +335,7 @@
     // Update the month helper view.
     _updateMonth : function () {
       if (this._showMonth === undefined || this._showMonth > 12)
-	this._showMonth = 1;
+        this._showMonth = 1;
 
       this._mElement.firstChild.data = loc.MONTH[this._showMonth-1];
       this._selectMonth();
@@ -338,10 +345,10 @@
     // Check if the viewed month is current
     _selectMonth : function () {
       if (this._showYear === this.select()['year'] &&
-	  this._showMonth === this.select()['month'])
-	this._mElement.classList.add('selected');
+          this._showMonth === this.select()['month'])
+        this._mElement.classList.add('selected');
       else
-	this._mElement.classList.remove('selected');
+        this._mElement.classList.remove('selected');
     },
 
 
@@ -351,10 +358,10 @@
 
       // Localized day view
       var tr = table.appendChild(d.createElement('thead'))
-	.appendChild(d.createElement('tr'));
+          .appendChild(d.createElement('tr'));
       for (var i = 0; i < 7; i++) {
-	tr.appendChild(d.createElement('th'))
-	  .appendChild(d.createTextNode(loc.WDAY[i]));
+        tr.appendChild(d.createElement('th'))
+          .appendChild(d.createTextNode(loc.WDAY[i]));
       };
 
       this._dBElement = this._dayBody();
@@ -365,22 +372,22 @@
 
     _dayBody : function () {
       var showDate = new Date(
-	this._showYear,
-	this._showMonth - 1,
-	1,
-	0,
-	0,
-	0,
-	0
+        this._showYear,
+        this._showMonth - 1,
+        1,
+        0,
+        0,
+        0,
+        0
       );
       var date = new Date(
-	this._showYear,
-	this._showMonth - 1,
-	1,
-	0,
-	0,
-	0,
-	0
+        this._showYear,
+        this._showMonth - 1,
+        1,
+        0,
+        0,
+        0,
+        0
       );
       var today = new Date();
       var that = this;
@@ -388,11 +395,11 @@
       // What happens, in case someone clicks
       // on a date
       var click = function () {
-	that.set(
-	  that._showYear,
-	  that._showMonth,
-	  parseInt(this.firstChild.data)
-	);
+        that.set(
+          that._showYear,
+          that._showMonth,
+          parseInt(this.firstChild.data)
+        );
       };
 
       // Skip back to the previous monday (may be in the last month)
@@ -405,46 +412,46 @@
       // Iterate over all days of the table
       while (1) {
 
-	// Loop through the week
-	var tr = tb.appendChild(d.createElement('tr'));
-	for (var i = 0; i < 7; i++) {
-	  var td = tr.appendChild(d.createElement('td'));
+        // Loop through the week
+        var tr = tb.appendChild(d.createElement('tr'));
+        for (var i = 0; i < 7; i++) {
+          var td = tr.appendChild(d.createElement('td'));
+          
+          // Not part of the current month
+          if (date.getMonth() !== showDate.getMonth()) {
+            td.classList.add('out');
+          }
+          else {
+            td.onclick = click;
+          };
+    
+          // This is the current day
+          if (date.getDate()     === today.getDate() &&
+              date.getMonth()    === today.getMonth() &&
+              date.getFullYear() === today.getFullYear()) {
+            td.classList.add('today');
+          };
 
-	  // Not part of the current month
-	  if (date.getMonth() !== showDate.getMonth()) {
-	    td.classList.add('out');
-	  }
-	  else {
-	    td.onclick = click;
-	  };
-	  
-	  // This is the current day
-	  if (date.getDate()     === today.getDate() &&
-	      date.getMonth()    === today.getMonth() &&
-	      date.getFullYear() === today.getFullYear()) {
-	    td.classList.add('today');
-	  };
+          // This is the day selected
+          if (s && s['day']) {
+            if (date.getDate()     === s['day'] &&
+                date.getMonth()    === s['month']-1 &&
+                date.getFullYear() === s['year']) {
+              td.classList.add('selected');
+            };
+          };
 
-	  // This is the day selected
-	  if (s && s['day']) {
-	    if (date.getDate()     === s['day'] &&
-		date.getMonth()    === s['month']-1 &&
-		date.getFullYear() === s['year']) {
-	      td.classList.add('selected');
-	    };
-	  };
+          // Add the current day to the table
+          td.appendChild(
+            d.createTextNode(date.getDate())
+          );
+    
+          // Next day
+          date.setDate(date.getDate() + 1);
+        };
 
-	  // Add the current day to the table
-	  td.appendChild(
-	    d.createTextNode(date.getDate())
-	  );
-	  
-	  // Next day
-	  date.setDate(date.getDate() + 1);
-	};
-
-	if (date.getMonth() !== showDate.getMonth())
-	  break;
+        if (date.getMonth() !== showDate.getMonth())
+          break;
       };
       return tb;
     },
@@ -453,18 +460,18 @@
     _updateDay : function () {
       var newBody = this._dayBody();
       this._dBElement.parentNode.replaceChild(
-	newBody,
-	this._dBElement
+        newBody,
+        this._dBElement
       );
       this._dBElement = newBody;
     },
 
     fromString : function (v) {
       if (v === undefined)
-	return false;
+        return false;
 
       if (!KorAP._validDateRE.test(v))
-	return false;
+        return false;
 
       var d = v.split('-', 3);
       d[0] = parseInt(d[0]);
diff --git a/dev/js/src/vc.js b/dev/js/src/vc.js
index 22b2c84..d6a26f2 100644
--- a/dev/js/src/vc.js
+++ b/dev/js/src/vc.js
@@ -58,8 +58,6 @@
 
   // ???
   KorAP._validStringMatchRE = new RegExp("^(?:eq|ne|contains(?:not)?|excludes)$");
-  KorAP._validDateMatchRE   = new RegExp("^[lg]?eq$");
-  KorAP._validDateRE        = new RegExp("^(?:\\d{4})(?:-\\d\\d(?:-\\d\\d)?)?$");
   KorAP._overrideStyles     = false;
 
   var loc = KorAP.Locale;
