Rewrote start and end, overall optimization.