mereged with bugfixes