bugfixes, better handling