Code cleanup and consistency changes