bugfixes and preparation for multi-script support