--- a/System.Data.SQLite/SQLiteConnection.cs
+++ b/System.Data.SQLite/SQLiteConnection.cs
@@ -762,18 +762,21 @@
         throw new InvalidOperationException();
 
       Close();
+        var properties = new SQLiteConnectionStringBuilder(ConnectionString);
 
       SortedList<string, string> opts = ParseConnectionString(_connectionString);
       string fileName;
 
-      if (Convert.ToInt32(FindKey(opts, "Version", "3"), CultureInfo.InvariantCulture) != 3)
-        throw new NotSupportedException("Only SQLite Version 3 is supported at this time");
-
-      fileName = FindKey(opts, "Data Source", "");
-
-      if (String.IsNullOrEmpty(fileName))
-      {
-        fileName = FindKey(opts, "Uri", "");
+        if(properties.Version != 3)
+            throw new NotSupportedException("Only SQLite Version 3 is supported at this time");
+
+
+
+        fileName = properties.DataSource;
+
+      if (String.IsNullOrEmpty(fileName))
+      {
+          fileName = properties.Uri;
         if (String.IsNullOrEmpty(fileName))
           throw new ArgumentException("Data Source cannot be empty.  Use :memory: to open an in-memory database");
         else
@@ -789,137 +792,144 @@
          fileName = Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().GetName().CodeBase) + fileName.Substring(1);
 #endif
        fileName = ExpandFileName(fileName);
-      }
-      try
-      {
-        bool usePooling = (SQLiteConvert.ToBoolean(FindKey(opts, "Pooling", Boolean.FalseString)) == true);
-        bool bUTF16 = (SQLiteConvert.ToBoolean(FindKey(opts, "UseUTF16Encoding", Boolean.FalseString)) == true);
-        int maxPoolSize = Convert.ToInt32(FindKey(opts, "Max Pool Size", "100"), CultureInfo.InvariantCulture);
-
-        _defaultTimeout = Convert.ToInt32(FindKey(opts, "Default Timeout", "30"), CultureInfo.CurrentCulture);
-
-        _defaultIsolation = (IsolationLevel)Enum.Parse(typeof(IsolationLevel), FindKey(opts, "Default IsolationLevel", "Serializable"), true);
-        if (_defaultIsolation != IsolationLevel.Serializable && _defaultIsolation != IsolationLevel.ReadCommitted)
-          throw new NotSupportedException("Invalid Default IsolationLevel specified");
-
-        SQLiteDateFormats dateFormat = (SQLiteDateFormats)Enum.Parse(typeof(SQLiteDateFormats), FindKey(opts, "DateTimeFormat", "ISO8601"), true);
-        //string temp = FindKey(opts, "DateTimeFormat", "ISO8601");
-        //if (String.Compare(temp, "ticks", StringComparison.OrdinalIgnoreCase) == 0) dateFormat = SQLiteDateFormats.Ticks;
-        //else if (String.Compare(temp, "julianday", StringComparison.OrdinalIgnoreCase) == 0) dateFormat = SQLiteDateFormats.JulianDay;
-
-        if (bUTF16) // SQLite automatically sets the encoding of the database to UTF16 if called from sqlite3_open16()
-          _sql = new SQLite3_UTF16(dateFormat);
-        else
-          _sql = new SQLite3(dateFormat);
-
-        SQLiteOpenFlagsEnum flags = SQLiteOpenFlagsEnum.None;
-
-        if (SQLiteConvert.ToBoolean(FindKey(opts, "FailIfMissing", Boolean.FalseString)) == false)
-          flags |= SQLiteOpenFlagsEnum.Create;
-
-        if (SQLiteConvert.ToBoolean(FindKey(opts, "Read Only", Boolean.FalseString)) == true)
-          flags |= SQLiteOpenFlagsEnum.ReadOnly;
-        else
-          flags |= SQLiteOpenFlagsEnum.ReadWrite;
-
-        _sql.Open(fileName, flags, maxPoolSize, usePooling);
-
-        _binaryGuid = (SQLiteConvert.ToBoolean(FindKey(opts, "BinaryGUID", Boolean.TrueString)) == true);
-
-        string password = FindKey(opts, "Password", null);
-
-        if (String.IsNullOrEmpty(password) == false)
-          _sql.SetPassword(System.Text.UTF8Encoding.UTF8.GetBytes(password));
-        else if (_password != null)
-          _sql.SetPassword(_password);
-        _password = null;
-
-        _dataSource = Path.GetFileNameWithoutExtension(fileName);
-
-        _version++;
-
-        ConnectionState oldstate = _connectionState;
-        _connectionState = ConnectionState.Open;
-        try
-        {
-          using (SQLiteCommand cmd = CreateCommand())
-          {
-            string defValue;
-
-            if (fileName != ":memory:")
-            {
-              defValue = FindKey(opts, "Page Size", "1024");
-              if (Convert.ToInt32(defValue, CultureInfo.InvariantCulture) != 1024)
-              {
-                cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA page_size={0}", defValue);
-                cmd.ExecuteNonQuery();
-              }
-            }
-
-            defValue = FindKey(opts, "Max Page Count", "0");
-            if (Convert.ToInt32(defValue, CultureInfo.InvariantCulture) != 0)
-            {
-              cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA max_page_count={0}", defValue);
-              cmd.ExecuteNonQuery();
-            }
-
-            defValue = FindKey(opts, "Legacy Format", Boolean.FalseString);
-            cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA legacy_file_format={0}", SQLiteConvert.ToBoolean(defValue) == true ? "ON" : "OFF");
-            cmd.ExecuteNonQuery();
-
-            defValue = FindKey(opts, "Synchronous", "Normal");
-            if (String.Compare(defValue, "Full", StringComparison.OrdinalIgnoreCase) != 0)
-            {
-              cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA synchronous={0}", defValue);
-              cmd.ExecuteNonQuery();
-            }
-
-            defValue = FindKey(opts, "Cache Size", "2000");
-            if (Convert.ToInt32(defValue, CultureInfo.InvariantCulture) != 2000)
-            {
-              cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA cache_size={0}", defValue);
-              cmd.ExecuteNonQuery();
-            }
-
-            defValue = FindKey(opts, "Journal Mode", "Delete");
-            if (String.Compare(defValue, "Delete", StringComparison.OrdinalIgnoreCase) != 0)
-            {
-              cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA journal_mode={0}", defValue);
-              cmd.ExecuteNonQuery();
-            }
-
-            defValue = FindKey(opts, "Foreign Keys", Boolean.FalseString);
-            cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA foreign_keys={0}", SQLiteConvert.ToBoolean(defValue) == true ? "ON" : "OFF");
-            cmd.ExecuteNonQuery();
-          }
-
-          if (_commitHandler != null)
-            _sql.SetCommitHook(_commitCallback);
-
-          if (_updateHandler != null)
-            _sql.SetUpdateHook(_updateCallback);
-
-          if (_rollbackHandler != null)
-            _sql.SetRollbackHook(_rollbackCallback);
-
-#if !PLATFORM_COMPACTFRAMEWORK
-          if (Transactions.Transaction.Current != null && SQLiteConvert.ToBoolean(FindKey(opts, "Enlist", Boolean.TrueString)) == true)
-            EnlistTransaction(Transactions.Transaction.Current);
-#endif
-
-          _connectionState = oldstate;
-          OnStateChange(ConnectionState.Open);
-        }
-        catch
-        {
-          _connectionState = oldstate;
-          throw;
-        }
-      }
-      catch (SQLiteException)
-      {
-        Close();
-        throw;
+      }
+      try
+      {
+
+          //bool usePooling = (SQLiteConvert.ToBoolean(FindKey(opts, "Pooling", Boolean.FalseString)) == true);
+          //bool bUTF16 = (SQLiteConvert.ToBoolean(FindKey(opts, "UseUTF16Encoding", Boolean.FalseString)) == true);
+          //int maxPoolSize = Convert.ToInt32(FindKey(opts, "Max Pool Size", "100"), CultureInfo.InvariantCulture);
+
+          _defaultTimeout = properties.DefaultTimeout;
+          _binaryGuid = properties.BinaryGUID;
+          _defaultIsolation = properties.DefaultIsolationLevel;
+
+          if (_defaultIsolation != IsolationLevel.Serializable && _defaultIsolation != IsolationLevel.ReadCommitted)
+              throw new NotSupportedException("Invalid Default IsolationLevel specified");
+
+          SQLiteDateFormats dateFormat =
+              (SQLiteDateFormats)
+              Enum.Parse(typeof (SQLiteDateFormats), FindKey(opts, "DateTimeFormat", "ISO8601"), true);
+          //string temp = FindKey(opts, "DateTimeFormat", "ISO8601");
+          //if (String.Compare(temp, "ticks", StringComparison.OrdinalIgnoreCase) == 0) dateFormat = SQLiteDateFormats.Ticks;
+          //else if (String.Compare(temp, "julianday", StringComparison.OrdinalIgnoreCase) == 0) dateFormat = SQLiteDateFormats.JulianDay;
+
+          if (properties.UseUTF16Encoding)
+              // SQLite automatically sets the encoding of the database to UTF16 if called from sqlite3_open16()
+              _sql = new SQLite3_UTF16(dateFormat);
+          else
+              _sql = new SQLiteBase(dateFormat);
+
+          SQLiteOpenFlagsEnum flags = SQLiteOpenFlagsEnum.None;
+
+          if (!properties.FailIfMissing)
+              flags |= SQLiteOpenFlagsEnum.Create;
+
+          if (properties.ReadOnly)
+              flags |= SQLiteOpenFlagsEnum.ReadOnly;
+          else
+              flags |= SQLiteOpenFlagsEnum.ReadWrite;
+
+          _sql.Open(fileName, flags, properties.MaxPoolSize, properties.Pooling);
+
+
+
+          string password = FindKey(opts, "Password", null);
+
+          if (String.IsNullOrEmpty(password) == false)
+              _sql.SetPassword(System.Text.UTF8Encoding.UTF8.GetBytes(password));
+          else if (_password != null)
+              _sql.SetPassword(_password);
+          _password = null;
+
+          _dataSource = Path.GetFileNameWithoutExtension(fileName);
+
+          _version++;
+
+          ConnectionState oldstate = _connectionState;
+          _connectionState = ConnectionState.Open;
+          try
+          {
+              using (SQLiteCommand cmd = CreateCommand())
+              {
+                  string defValue;
+
+                  if (fileName != ":memory:")
+                  {
+                      
+                      if (properties.PageSize != 1024)
+                      {
+                          cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA page_size={0}", properties.PageSize);
+                          cmd.ExecuteNonQuery();
+                      }
+                  }
+
+                  
+                  if (properties.MaxPageCount != 0)
+                  {
+                      cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA max_page_count={0}",
+                                                      properties.MaxPageCount);
+                      cmd.ExecuteNonQuery();
+                  }
+
+                  
+                  cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA legacy_file_format={0}", properties.LegacyFormat? "ON" : "OFF");
+                  cmd.ExecuteNonQuery();
+
+                  
+                  if (properties.SyncMode != SynchronizationModes.Normal)
+                  {
+                      cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA synchronous={0}", properties.SyncMode);
+                      cmd.ExecuteNonQuery();
+                  }
+
+                  
+                  if (properties.CacheSize != 2000)
+                  {
+                      cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA cache_size={0}", properties.CacheSize);
+                      cmd.ExecuteNonQuery();
+                  }
+
+                  
+                  if (properties.JournalMode != SQLiteJournalModeEnum.Delete)
+                  {
+                      cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA journal_mode={0}", properties.JournalMode);
+                      cmd.ExecuteNonQuery();
+                  }
+
+                  
+                  cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA foreign_keys={0}",
+                                                  properties.ForeignKeys? "ON" : "OFF");
+                  cmd.ExecuteNonQuery();
+              }
+
+              if (_commitHandler != null)
+                  _sql.SetCommitHook(_commitCallback);
+
+              if (_updateHandler != null)
+                  _sql.SetUpdateHook(_updateCallback);
+
+              if (_rollbackHandler != null)
+                  _sql.SetRollbackHook(_rollbackCallback);
+
+#if !PLATFORM_COMPACTFRAMEWORK
+              if (Transactions.Transaction.Current != null &&properties.Enlist)
+                  EnlistTransaction(Transactions.Transaction.Current);
+#endif
+
+              _connectionState = oldstate;
+              OnStateChange(ConnectionState.Open);
+          }
+          catch
+          {
+              _connectionState = oldstate;
+              throw;
+          }
+      }
+      catch (SQLiteException)
+      {
+          Close();
+          throw;
       }
     }
 
@@ -945,10 +955,6 @@
       get
       {
         return SQLiteVersion;
-        //if (_connectionState != ConnectionState.Open)
-        //  throw new InvalidOperationException();
-
-        //return _sql.Version;
       }
     }
 
@@ -957,7 +963,7 @@
     /// </summary>
     public static string SQLiteVersion
     {
-      get { return SQLite3.SQLiteVersion; }
+      get { return SQLiteBase.SQLiteVersion; }
     }
 
     /// <summary>
@@ -1034,7 +1040,7 @@
     /// </summary>
     /// <param name="sourceFile">The database filename to expand</param>
     /// <returns>The expanded path and filename of the filename</returns>
-    private string ExpandFileName(string sourceFile)
+    public static string ExpandFileName(string sourceFile)
     {
       if (String.IsNullOrEmpty(sourceFile)) return sourceFile;
 
@@ -2253,123 +2259,5 @@
     {
       _rollbackHandler(this, EventArgs.Empty);
     }
-  }
-
-  /// <summary>
-  /// The I/O file cache flushing behavior for the connection
-  /// </summary>
-  public enum SynchronizationModes
-  {
-    /// <summary>
-    /// Normal file flushing at critical sections of the code
-    /// </summary>
-    Normal = 0,
-    /// <summary>
-    /// Full file flushing after every write operation
-    /// </summary>
-    Full = 1,
-    /// <summary>
-    /// Use the default operating system's file flushing, SQLite does not explicitly flush the file buffers after writing
-    /// </summary>
-    Off = 2,
-  }
-
-#if !PLATFORM_COMPACTFRAMEWORK
-  [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-#endif
-  internal delegate void SQLiteUpdateCallback(IntPtr puser, int type, IntPtr database, IntPtr table, Int64 rowid);
-#if !PLATFORM_COMPACTFRAMEWORK
-  [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-#endif
-  internal delegate int SQLiteCommitCallback(IntPtr puser);
-#if !PLATFORM_COMPACTFRAMEWORK
-  [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-#endif
-  internal delegate void SQLiteRollbackCallback(IntPtr puser);
-
-  /// <summary>
-  /// Raised when a transaction is about to be committed.  To roll back a transaction, set the 
-  /// rollbackTrans boolean value to true.
-  /// </summary>
-  /// <param name="sender">The connection committing the transaction</param>
-  /// <param name="e">Event arguments on the transaction</param>
-  public delegate void SQLiteCommitHandler(object sender, CommitEventArgs e);
-
-  /// <summary>
-  /// Raised when data is inserted, updated and deleted on a given connection
-  /// </summary>
-  /// <param name="sender">The connection committing the transaction</param>
-  /// <param name="e">The event parameters which triggered the event</param>
-  public delegate void SQLiteUpdateEventHandler(object sender, UpdateEventArgs e);
-
-  /// <summary>
-  /// Whenever an update event is triggered on a connection, this enum will indicate
-  /// exactly what type of operation is being performed.
-  /// </summary>
-  public enum UpdateEventType
-  {
-    /// <summary>
-    /// A row is being deleted from the given database and table
-    /// </summary>
-    Delete = 9,
-    /// <summary>
-    /// A row is being inserted into the table.
-    /// </summary>
-    Insert = 18,
-    /// <summary>
-    /// A row is being updated in the table.
-    /// </summary>
-    Update = 23,
-  }
-
-  /// <summary>
-  /// Passed during an Update callback, these event arguments detail the type of update operation being performed
-  /// on the given connection.
-  /// </summary>
-  public class UpdateEventArgs : EventArgs
-  {
-    /// <summary>
-    /// The name of the database being updated (usually "main" but can be any attached or temporary database)
-    /// </summary>
-    public readonly string Database;
-
-    /// <summary>
-    /// The name of the table being updated
-    /// </summary>
-    public readonly string Table;
-
-    /// <summary>
-    /// The type of update being performed (insert/update/delete)
-    /// </summary>
-    public readonly UpdateEventType Event;
-
-    /// <summary>
-    /// The RowId affected by this update.
-    /// </summary>
-    public readonly Int64 RowId;
-
-    internal UpdateEventArgs(string database, string table, UpdateEventType eventType, Int64 rowid)
-    {
-      Database = database;
-      Table = table;
-      Event = eventType;
-      RowId = rowid;
-    }
-  }
-
-  /// <summary>
-  /// Event arguments raised when a transaction is being committed
-  /// </summary>
-  public class CommitEventArgs : EventArgs
-  {
-    internal CommitEventArgs()
-    {
-    }
-
-    /// <summary>
-    /// Set to true to abort the transaction and trigger a rollback
-    /// </summary>
-    public bool AbortTransaction;
-  }
-
+  }
 }