some improvements due to the work on TinsPHP