Refactor of Major Issues

Fixed: Refactored a whole bunch of code based on automatic suggestions.