Many fixes and improvements, plus some new classes