bugfixes and some polishing