Replaced deprecated split wih preg_split, fixed database schema