Refactored, cleanedup, and reduced complexity in several functions and areas of the code. Primarily input and output and main related.