Cleanup code and remove unused references.