Cleaned up some of the code.
Merged conflict.