I like these comments that break up major pieces of functionality.  I would love to see you break it into different files.  This file is still probably longer than you'd want it, but got job coalescing the functionality together.