major bugfixes and enhancements