fixes #251, #216, #206, #218, #185, #217