Refactor Main Source File

Just a quick clean up, removing some redundancies and extracting concerns into their own methods. Still more can be done, but this is a start.
Did you mean to change this from DESC to ASC?