Completely reorganized code layout to give it a much more organized feel.