Moved some things around to clean up the code even more.
Resolved pull conflict.