Code cleanup and protection