Massive code cleanup and formatting, Minor Fixes