Two masses attached to a spring I'm trying to understand the solution of the following problem.

Two masses $m_{1}$ and $m_{2}$ slide freely in a horizontal frictionless track and are connected by a spring whose force constant is $K$. Find the the frequency of oscilatory motion for this system.

In the solutions manual, it is considered that $x_{1}$ and $x_{2}$ are the coordinates of $m_{1}$ and $m_{2}$, respectively, and the length of the spring at equilibrium is $l$. Then, it is defined that, the equations of motion for each mass are:
$$ m_{1}\ddot x_{1} = -k(x_{1} - x_{2} + l), \\
  m_{2}\ddot x_{2} = -k(x_{2} - x_{1} - l).$$
And, with some algebraic manipulations, we arrive at the answer.
My question is about the right hand side of these two equations. Why is the displacement in the restoring force equal to the difference between the positions plus the length of the spring in the first equation and minus on the second? What is the behavior of the system during the move? What changes in the analysis when I consider the frictional force? Could I consider that this motion has some relationship with the center of mass of the system?
 A: Given a spring with spring constant $k$ whose extension is in the direction $x$, the magnitude of the force that the spring exerts is given by
$$
  |\vec{F}| = F = k|L-l|
$$
where $L$ is its length and $l$ is its equilibrium length.  Now, imagine that the two masses are at positions $x_1$ and $x_2$ with $x_2>x_1$, then the length of the spring is given by $L = x_2 - x_1$ so that the magnitude of the force exerted by the spring is given by
$$
  |\vec{F}| = F = k|(x_2-x_1) - l|
$$
Now, if $x_2 - x_1>l$, then the spring is stretched in which case the mass on the right feels a force of this magnitude to the left, and the mass on the left feels a force of the same mangitude to the right;
\begin{align}
  F_1 = k(x_2-x_1 - l) \\
  F_2 = -k(x_2 - x_1 - l)
\end{align}
This results in the following two equations of motion
\begin{align}
  m\ddot x_1 = -k(x_1-x_2 + l) \\
  m \ddot x_2 = -k(x_2 - x_1 - l)
\end{align}
Essentially, the difference in the sign of $l$ can be attributed to Newton's third law; the forces on each mass must be equal and magnitude, but opposite in direction.
If friction were included on the surface, say for the sake of concreteness that the coefficient of kinetic friction is $\mu_k$, then each object experiences a force equal in magnitude to $\mu_k m_1g$ for mass 1 and $\mu_k m_2 g$ for mass $2$.  The sign of the friction force term must be chosen so as to always give a friction force that is opposite the direction of motion.  One way to do this is to multiply the force's magntiude by $-\dot x/|\dot x|$  which is $-1$ when the object is moving to the right, and $+1$ when the object is moving to the left. 
Thus, with friction the equations of motion can be written as
\begin{align}
  m\ddot x_1 = -k(x_1-x_2 + l) - \mu_k m_1g\frac{\dot x_1}{|\dot x_1|} \\
  m \ddot x_2 = -k(x_2 - x_1 - l) - \mu_k m_2g\frac{\dot x_2}{|\dot x_2|}
\end{align}
As you can tell, these differential equations are considerably harder to solve in general.
A: You really need to start with a bit of intuition about what is going on not just regurgitate equations. Try to imagine in your head those 2 masses oscillating. First imagine if the masses are equal. Then if unequal. YES of course the center of mass is totally important. Assume first the center of mass is not moving, just each mass bobbing to and fro in the same zone. So first calculate center of mass location.
