Various bugfixes & enhancements