ticket3: merged with bugfixes from ticket2