Cleaned up code a bit. Solved preg_split() problem.