Reorganizing TSX code