Heavily patched for TYPO3 6.2 compatibility.