various minor fixes + ssalbiz's important fix