Cleaned up and reorganized a bit.