TL: Bugfixes and code cleanup