many changes and hacks. (for TNM)