Code translation and cleanup