Bunch of code cleanup and removing IDE warnings.