Drastically cleaned and reduced code.