Cleanup and rearrange.
Cleanup and error fixes.