Code cleanup and structure change.