More code cleanup and minor changes